0s autopkgtest [17:23:40]: starting date and time: 2025-05-06 17:23:40+0000 0s autopkgtest [17:23:40]: git checkout: 9986aa8c Merge branch 'skia/fix_network_interface' into 'ubuntu/production' 0s autopkgtest [17:23:40]: host juju-7f2275-prod-proposed-migration-environment-23; command line: /home/ubuntu/autopkgtest/runner/autopkgtest --output-dir /tmp/autopkgtest-work.m9l40nhc/out --timeout-copy=6000 --setup-commands /home/ubuntu/autopkgtest-cloud/worker-config-production/setup-canonical.sh --apt-pocket=proposed=src:python-zstandard,src:matplotlib --apt-upgrade pandas --timeout-short=300 --timeout-copy=20000 --timeout-test=20000 --timeout-build=20000 '--env=ADT_TEST_TRIGGERS=python-zstandard/0.23.0-4 matplotlib/3.10.1+dfsg1-3' -- ssh -s /home/ubuntu/autopkgtest/ssh-setup/nova -- --flavor autopkgtest-big --security-groups autopkgtest-juju-7f2275-prod-proposed-migration-environment-23@bos03-arm64-15.secgroup --name adt-questing-arm64-pandas-20250506-172339-juju-7f2275-prod-proposed-migration-environment-23-d8235e52-98a0-4e47-8dcd-6da08e0a828f --image adt/ubuntu-questing-arm64-server --keyname testbed-juju-7f2275-prod-proposed-migration-environment-23 --net-id=net_prod-proposed-migration -e TERM=linux --mirror=http://ftpmaster.internal/ubuntu/ 129s autopkgtest [17:25:49]: testbed dpkg architecture: arm64 129s autopkgtest [17:25:49]: testbed apt version: 3.0.0 129s autopkgtest [17:25:49]: @@@@@@@@@@@@@@@@@@@@ test bed setup 130s autopkgtest [17:25:50]: testbed release detected to be: None 130s autopkgtest [17:25:50]: updating testbed package index (apt update) 131s Get:1 http://ftpmaster.internal/ubuntu questing-proposed InRelease [110 kB] 131s Hit:2 http://ftpmaster.internal/ubuntu questing InRelease 131s Hit:3 http://ftpmaster.internal/ubuntu questing-updates InRelease 131s Hit:4 http://ftpmaster.internal/ubuntu questing-security InRelease 131s Get:5 http://ftpmaster.internal/ubuntu questing-proposed/main Sources [67.8 kB] 131s Get:6 http://ftpmaster.internal/ubuntu questing-proposed/multiverse Sources [27.3 kB] 131s Get:7 http://ftpmaster.internal/ubuntu questing-proposed/universe Sources [580 kB] 131s Get:8 http://ftpmaster.internal/ubuntu questing-proposed/main arm64 Packages [125 kB] 131s Get:9 http://ftpmaster.internal/ubuntu questing-proposed/universe arm64 Packages [639 kB] 131s Get:10 http://ftpmaster.internal/ubuntu questing-proposed/multiverse arm64 Packages [16.1 kB] 131s Fetched 1566 kB in 1s (1772 kB/s) 132s Reading package lists... 133s autopkgtest [17:25:53]: upgrading testbed (apt dist-upgrade and autopurge) 133s Reading package lists... 133s Building dependency tree... 133s Reading state information... 134s Calculating upgrade...Starting pkgProblemResolver with broken count: 0 134s Starting 2 pkgProblemResolver with broken count: 0 134s Done 135s Entering ResolveByKeep 135s 135s Calculating upgrade... 135s The following packages will be upgraded: 135s libpython3.12-minimal libpython3.12-stdlib libpython3.12t64 136s 3 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 136s Need to get 5180 kB of archives. 136s After this operation, 291 kB disk space will be freed. 136s Get:1 http://ftpmaster.internal/ubuntu questing-proposed/universe arm64 libpython3.12t64 arm64 3.12.10-1 [2314 kB] 136s Get:2 http://ftpmaster.internal/ubuntu questing-proposed/universe arm64 libpython3.12-stdlib arm64 3.12.10-1 [2029 kB] 136s Get:3 http://ftpmaster.internal/ubuntu questing-proposed/universe arm64 libpython3.12-minimal arm64 3.12.10-1 [836 kB] 137s Fetched 5180 kB in 1s (6154 kB/s) 137s (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 ... 117830 files and directories currently installed.) 137s Preparing to unpack .../libpython3.12t64_3.12.10-1_arm64.deb ... 137s Unpacking libpython3.12t64:arm64 (3.12.10-1) over (3.12.8-3) ... 137s Preparing to unpack .../libpython3.12-stdlib_3.12.10-1_arm64.deb ... 137s Unpacking libpython3.12-stdlib:arm64 (3.12.10-1) over (3.12.8-3) ... 137s Preparing to unpack .../libpython3.12-minimal_3.12.10-1_arm64.deb ... 137s Unpacking libpython3.12-minimal:arm64 (3.12.10-1) over (3.12.8-3) ... 138s Setting up libpython3.12-minimal:arm64 (3.12.10-1) ... 138s Setting up libpython3.12-stdlib:arm64 (3.12.10-1) ... 138s Setting up libpython3.12t64:arm64 (3.12.10-1) ... 138s Processing triggers for libc-bin (2.41-6ubuntu1) ... 138s Reading package lists... 138s Building dependency tree... 138s Reading state information... 138s Starting pkgProblemResolver with broken count: 0 139s Starting 2 pkgProblemResolver with broken count: 0 139s Done 139s Solving dependencies... 139s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 142s autopkgtest [17:26:02]: testbed running kernel: Linux 6.14.0-15-generic #15-Ubuntu SMP PREEMPT_DYNAMIC Sun Apr 6 14:37:51 UTC 2025 142s autopkgtest [17:26:02]: @@@@@@@@@@@@@@@@@@@@ apt-source pandas 146s Get:1 http://ftpmaster.internal/ubuntu questing/universe pandas 2.2.3+dfsg-9 (dsc) [5546 B] 146s Get:2 http://ftpmaster.internal/ubuntu questing/universe pandas 2.2.3+dfsg-9 (tar) [11.2 MB] 146s Get:3 http://ftpmaster.internal/ubuntu questing/universe pandas 2.2.3+dfsg-9 (diff) [112 kB] 146s gpgv: Signature made Sat Mar 29 14:46:18 2025 UTC 146s gpgv: using RSA key 67CB311005C4EDBE32175308DEE50D0D567EA266 146s gpgv: issuer "rebecca_palmer@zoho.com" 146s gpgv: Can't check signature: No public key 146s dpkg-source: warning: cannot verify inline signature for ./pandas_2.2.3+dfsg-9.dsc: no acceptable signature found 147s autopkgtest [17:26:07]: testing package pandas version 2.2.3+dfsg-9 148s autopkgtest [17:26:08]: build not needed 151s autopkgtest [17:26:10]: test command1: preparing testbed 151s Reading package lists... 151s Building dependency tree... 151s Reading state information... 152s Starting pkgProblemResolver with broken count: 0 152s Starting 2 pkgProblemResolver with broken count: 0 152s Done 154s The following NEW packages will be installed: 154s libblas3 libgfortran5 liblapack3 python3-dateutil python3-numpy 154s python3-numpy-dev python3-pandas python3-pandas-lib python3-pytz 154s 0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded. 154s Need to get 15.0 MB of archives. 154s After this operation, 75.0 MB of additional disk space will be used. 154s Get:1 http://ftpmaster.internal/ubuntu questing/main arm64 python3-numpy-dev arm64 1:2.2.4+ds-1 [146 kB] 154s Get:2 http://ftpmaster.internal/ubuntu questing/main arm64 libblas3 arm64 3.12.1-2 [161 kB] 154s Get:3 http://ftpmaster.internal/ubuntu questing/main arm64 libgfortran5 arm64 15.1.0-2ubuntu1 [445 kB] 154s Get:4 http://ftpmaster.internal/ubuntu questing/main arm64 liblapack3 arm64 3.12.1-2 [2307 kB] 154s Get:5 http://ftpmaster.internal/ubuntu questing/main arm64 python3-numpy arm64 1:2.2.4+ds-1 [3990 kB] 154s Get:6 http://ftpmaster.internal/ubuntu questing/main arm64 python3-dateutil all 2.9.0-4 [80.3 kB] 154s Get:7 http://ftpmaster.internal/ubuntu questing/main arm64 python3-pytz all 2025.1-3 [162 kB] 154s Get:8 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-pandas-lib arm64 2.2.3+dfsg-9 [4579 kB] 155s Get:9 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-pandas all 2.2.3+dfsg-9 [3112 kB] 155s Fetched 15.0 MB in 1s (13.4 MB/s) 155s Selecting previously unselected package python3-numpy-dev:arm64. 155s (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 ... 117830 files and directories currently installed.) 155s Preparing to unpack .../0-python3-numpy-dev_1%3a2.2.4+ds-1_arm64.deb ... 155s Unpacking python3-numpy-dev:arm64 (1:2.2.4+ds-1) ... 155s Selecting previously unselected package libblas3:arm64. 155s Preparing to unpack .../1-libblas3_3.12.1-2_arm64.deb ... 155s Unpacking libblas3:arm64 (3.12.1-2) ... 155s Selecting previously unselected package libgfortran5:arm64. 156s Preparing to unpack .../2-libgfortran5_15.1.0-2ubuntu1_arm64.deb ... 156s Unpacking libgfortran5:arm64 (15.1.0-2ubuntu1) ... 156s Selecting previously unselected package liblapack3:arm64. 156s Preparing to unpack .../3-liblapack3_3.12.1-2_arm64.deb ... 156s Unpacking liblapack3:arm64 (3.12.1-2) ... 156s Selecting previously unselected package python3-numpy. 156s Preparing to unpack .../4-python3-numpy_1%3a2.2.4+ds-1_arm64.deb ... 156s Unpacking python3-numpy (1:2.2.4+ds-1) ... 156s Selecting previously unselected package python3-dateutil. 156s Preparing to unpack .../5-python3-dateutil_2.9.0-4_all.deb ... 156s Unpacking python3-dateutil (2.9.0-4) ... 156s Selecting previously unselected package python3-pytz. 156s Preparing to unpack .../6-python3-pytz_2025.1-3_all.deb ... 156s Unpacking python3-pytz (2025.1-3) ... 156s Selecting previously unselected package python3-pandas-lib:arm64. 156s Preparing to unpack .../7-python3-pandas-lib_2.2.3+dfsg-9_arm64.deb ... 156s Unpacking python3-pandas-lib:arm64 (2.2.3+dfsg-9) ... 156s Selecting previously unselected package python3-pandas. 156s Preparing to unpack .../8-python3-pandas_2.2.3+dfsg-9_all.deb ... 156s Unpacking python3-pandas (2.2.3+dfsg-9) ... 156s Setting up python3-pytz (2025.1-3) ... 157s Setting up libblas3:arm64 (3.12.1-2) ... 157s update-alternatives: using /usr/lib/aarch64-linux-gnu/blas/libblas.so.3 to provide /usr/lib/aarch64-linux-gnu/libblas.so.3 (libblas.so.3-aarch64-linux-gnu) in auto mode 157s Setting up python3-numpy-dev:arm64 (1:2.2.4+ds-1) ... 157s Setting up libgfortran5:arm64 (15.1.0-2ubuntu1) ... 157s Setting up python3-dateutil (2.9.0-4) ... 157s Setting up liblapack3:arm64 (3.12.1-2) ... 157s update-alternatives: using /usr/lib/aarch64-linux-gnu/lapack/liblapack.so.3 to provide /usr/lib/aarch64-linux-gnu/liblapack.so.3 (liblapack.so.3-aarch64-linux-gnu) in auto mode 157s Setting up python3-numpy (1:2.2.4+ds-1) ... 160s Setting up python3-pandas-lib:arm64 (2.2.3+dfsg-9) ... 160s Setting up python3-pandas (2.2.3+dfsg-9) ... 165s Processing triggers for man-db (2.13.1-1) ... 165s Processing triggers for libc-bin (2.41-6ubuntu1) ... 166s autopkgtest [17:26:26]: test command1: cd "$AUTOPKGTEST_TMP" && python3 -c "import pandas;a=pandas.DataFrame([[1,2],[3,4]])" 166s autopkgtest [17:26:26]: test command1: [----------------------- 168s autopkgtest [17:26:28]: test command1: -----------------------] 168s autopkgtest [17:26:28]: test command1: - - - - - - - - - - results - - - - - - - - - - 168s command1 PASS 168s autopkgtest [17:26:28]: test unittests3: preparing testbed 169s Reading package lists... 169s Building dependency tree... 169s Reading state information... 170s Starting pkgProblemResolver with broken count: 1 170s Starting 2 pkgProblemResolver with broken count: 1 170s Investigating (0) python3-zstandard:arm64 < none -> 0.23.0-4 @un puN Ib > 170s Broken python3-zstandard:arm64 Depends on libzstd1:arm64 < 1.5.6+dfsg-2 @ii pK > (>= 1.5.7~) 170s Considering libzstd1:arm64 314 as a solution to python3-zstandard:arm64 4 170s Done 170s Some packages could not be installed. This may mean that you have 170s requested an impossible situation or if you are using the unstable 170s distribution that some required packages have not yet been created 170s or been moved out of Incoming. 170s The following information may help to resolve the situation: 170s 170s The following packages have unmet dependencies: 171s python3-zstandard : Depends: libzstd1 (>= 1.5.7~) but 1.5.6+dfsg-2 is to be installed 171s E: Unable to correct problems, you have held broken packages. 171s autopkgtest: WARNING: Test dependencies are unsatisfiable with using apt pinning. Retrying with using all packages from questing-proposed 171s Reading package lists... 172s Building dependency tree... 172s Reading state information... 173s Starting pkgProblemResolver with broken count: 0 173s Starting 2 pkgProblemResolver with broken count: 0 173s Done 174s The following NEW packages will be installed: 174s blt fontconfig fontconfig-config fonts-dejavu-core fonts-dejavu-mono 174s fonts-lyx libaec0 libavahi-client3 libavahi-common-data libavahi-common3 174s libblosc1 libblosc2-4 libcups2t64 libdeflate0 libdouble-conversion3 174s libegl-mesa0 libegl1 libfontconfig1 libfontenc1 libgbm1 libgl1 174s libgl1-mesa-dri libglvnd0 libglx-mesa0 libglx0 libgomp1 libgraphite2-3 174s libharfbuzz0b libhdf5-310 libice6 libimagequant0 libinput-bin libinput10 174s libjbig0 libjpeg-turbo8 libjpeg8 libjs-jquery libjs-jquery-ui liblbfgsb0 174s liblcms2-2 liblerc4 libmd4c0 libmtdev1t64 libopenjp2-7 libpcre2-16-0 174s libpixman-1-0 libqhull-r8.0 libqt5core5t64 libqt5dbus5t64 libqt5designer5 174s libqt5gui5t64 libqt5help5 libqt5network5t64 libqt5printsupport5t64 174s libqt5sql5t64 libqt5test5t64 libqt5widgets5t64 libqt5xml5t64 libraqm0 174s libsharpyuv0 libsm6 libsnappy1v5 libsz2 libtcl8.6 libtiff6 libtk8.6 174s libvulkan1 libwacom-common libwacom9 libwayland-client0 libwayland-server0 174s libwebp7 libwebpdemux2 libwebpmux3 libx11-xcb1 libxaw7 libxcb-dri3-0 174s libxcb-glx0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-present0 174s libxcb-randr0 libxcb-render-util0 libxcb-render0 libxcb-shape0 libxcb-shm0 174s libxcb-sync1 libxcb-util1 libxcb-xfixes0 libxcb-xinerama0 libxcb-xinput0 174s libxcb-xkb1 libxfont2 libxft2 libxkbcommon-x11-0 libxkbfile1 libxmu6 libxpm4 174s libxrandr2 libxrender1 libxshmfence1 libxslt1.1 libxss1 libxt6t64 174s libxxf86vm1 libzopfli1 locales-all mesa-libgallium python-matplotlib-data 174s python-tables-data python3-all python3-async-generator python3-bottleneck 174s python3-brotli python3-bs4 python3-click python3-cloudpickle 174s python3-contourpy python3-cpuinfo python3-cycler python3-dask 174s python3-decorator python3-defusedxml python3-et-xmlfile python3-execnet 174s python3-fonttools python3-fs python3-fsspec python3-greenlet 174s python3-html5lib python3-hypothesis python3-iniconfig python3-kiwisolver 174s python3-locket python3-lxml python3-lz4 python3-matplotlib python3-mpmath 174s python3-numexpr python3-odf python3-openpyxl python3-packaging python3-partd 174s python3-pil python3-pil.imagetk python3-platformdirs python3-pluggy 174s python3-py python3-pyqt5 python3-pyqt5.sip python3-pyreadstat python3-pytest 174s python3-pytest-asyncio python3-pytest-forked python3-pytest-localserver 174s python3-pytest-xdist python3-pytestqt python3-scipy python3-sortedcontainers 174s python3-soupsieve python3-sqlalchemy python3-sympy python3-tables 174s python3-tables-lib python3-tabulate python3-tk python3-toolz python3-tz 174s python3-ufolib2 python3-webencodings python3-werkzeug python3-xarray 174s python3-xlrd python3-xlsxwriter python3-zopfli python3-zstandard 174s python3.13-tk tk8.6-blt2.5 tzdata-legacy unicode-data x11-common 174s x11-xkb-utils xsel xserver-common xvfb 174s The following packages will be upgraded: 174s libpython3.13 libpython3.13-minimal libpython3.13-stdlib libzstd1 174s python3-pytz python3.13 python3.13-gdbm python3.13-minimal tzdata zstd 174s 10 upgraded, 186 newly installed, 0 to remove and 40 not upgraded. 174s Need to get 122 MB of archives. 174s After this operation, 662 MB of additional disk space will be used. 174s Get:1 http://ftpmaster.internal/ubuntu questing-proposed/main arm64 python3.13 arm64 3.13.3-2 [739 kB] 174s Get:2 http://ftpmaster.internal/ubuntu questing-proposed/main arm64 libpython3.13 arm64 3.13.3-2 [2281 kB] 174s Get:3 http://ftpmaster.internal/ubuntu questing-proposed/main arm64 libpython3.13-stdlib arm64 3.13.3-2 [2038 kB] 174s Get:4 http://ftpmaster.internal/ubuntu questing-proposed/main arm64 python3.13-minimal arm64 3.13.3-2 [2273 kB] 174s Get:5 http://ftpmaster.internal/ubuntu questing-proposed/main arm64 libpython3.13-minimal arm64 3.13.3-2 [881 kB] 174s Get:6 http://ftpmaster.internal/ubuntu questing-proposed/main arm64 tzdata all 2025b-3ubuntu1 [198 kB] 174s Get:7 http://ftpmaster.internal/ubuntu questing-proposed/main arm64 libzstd1 arm64 1.5.7+dfsg-1 [283 kB] 174s Get:8 http://ftpmaster.internal/ubuntu questing/main arm64 libtcl8.6 arm64 8.6.16+dfsg-1 [987 kB] 174s Get:9 http://ftpmaster.internal/ubuntu questing/main arm64 fonts-dejavu-mono all 2.37-8 [502 kB] 175s Get:10 http://ftpmaster.internal/ubuntu questing/main arm64 fonts-dejavu-core all 2.37-8 [835 kB] 175s Get:11 http://ftpmaster.internal/ubuntu questing/main arm64 fontconfig-config arm64 2.15.0-2.2ubuntu1 [37.9 kB] 175s Get:12 http://ftpmaster.internal/ubuntu questing/main arm64 libfontconfig1 arm64 2.15.0-2.2ubuntu1 [144 kB] 175s Get:13 http://ftpmaster.internal/ubuntu questing/main arm64 libxrender1 arm64 1:0.9.12-1 [19.5 kB] 175s Get:14 http://ftpmaster.internal/ubuntu questing/main arm64 libxft2 arm64 2.3.6-1build1 [44.1 kB] 175s Get:15 http://ftpmaster.internal/ubuntu questing/main arm64 x11-common all 1:7.7+23ubuntu4 [21.8 kB] 175s Get:16 http://ftpmaster.internal/ubuntu questing/main arm64 libxss1 arm64 1:1.2.3-1build3 [7244 B] 175s Get:17 http://ftpmaster.internal/ubuntu questing/main arm64 libtk8.6 arm64 8.6.16-1 [776 kB] 175s Get:18 http://ftpmaster.internal/ubuntu questing/main arm64 tk8.6-blt2.5 arm64 2.5.3+dfsg-8 [624 kB] 175s Get:19 http://ftpmaster.internal/ubuntu questing/main arm64 blt arm64 2.5.3+dfsg-8 [4824 B] 175s Get:20 http://ftpmaster.internal/ubuntu questing/main arm64 fontconfig arm64 2.15.0-2.2ubuntu1 [191 kB] 175s Get:21 http://ftpmaster.internal/ubuntu questing/universe arm64 fonts-lyx all 2.4.3-1 [171 kB] 175s Get:22 http://ftpmaster.internal/ubuntu questing/universe arm64 libaec0 arm64 1.1.3-1 [22.0 kB] 175s Get:23 http://ftpmaster.internal/ubuntu questing/main arm64 libavahi-common-data arm64 0.8-16ubuntu2 [31.0 kB] 175s Get:24 http://ftpmaster.internal/ubuntu questing/main arm64 libavahi-common3 arm64 0.8-16ubuntu2 [22.9 kB] 175s Get:25 http://ftpmaster.internal/ubuntu questing/main arm64 libavahi-client3 arm64 0.8-16ubuntu2 [26.9 kB] 175s Get:26 http://ftpmaster.internal/ubuntu questing/main arm64 libsnappy1v5 arm64 1.2.2-1 [30.5 kB] 175s Get:27 http://ftpmaster.internal/ubuntu questing/universe arm64 libblosc1 arm64 1.21.5+ds-1build1 [25.7 kB] 175s Get:28 http://ftpmaster.internal/ubuntu questing/universe arm64 libblosc2-4 arm64 2.17.1+ds-1 [158 kB] 175s Get:29 http://ftpmaster.internal/ubuntu questing/main arm64 libcups2t64 arm64 2.4.12-0ubuntu1 [272 kB] 175s Get:30 http://ftpmaster.internal/ubuntu questing/main arm64 libdeflate0 arm64 1.23-2 [46.4 kB] 175s Get:31 http://ftpmaster.internal/ubuntu questing/universe arm64 libdouble-conversion3 arm64 3.3.1-1 [38.8 kB] 175s Get:32 http://ftpmaster.internal/ubuntu questing/main arm64 libwayland-server0 arm64 1.23.1-3 [36.1 kB] 175s Get:33 http://ftpmaster.internal/ubuntu questing/main arm64 libx11-xcb1 arm64 2:1.8.12-1 [8098 B] 175s Get:34 http://ftpmaster.internal/ubuntu questing/main arm64 libxcb-dri3-0 arm64 1.17.0-2 [7606 B] 175s Get:35 http://ftpmaster.internal/ubuntu questing/main arm64 libxcb-present0 arm64 1.17.0-2 [6224 B] 175s Get:36 http://ftpmaster.internal/ubuntu questing/main arm64 libxcb-randr0 arm64 1.17.0-2 [18.5 kB] 175s Get:37 http://ftpmaster.internal/ubuntu questing/main arm64 libxcb-sync1 arm64 1.17.0-2 [9688 B] 175s Get:38 http://ftpmaster.internal/ubuntu questing/main arm64 libxcb-xfixes0 arm64 1.17.0-2 [10.6 kB] 175s Get:39 http://ftpmaster.internal/ubuntu questing/main arm64 libxshmfence1 arm64 1.3.3-1 [5378 B] 175s Get:40 http://ftpmaster.internal/ubuntu questing/main arm64 mesa-libgallium arm64 25.0.3-1ubuntu2 [9455 kB] 175s Get:41 http://ftpmaster.internal/ubuntu questing/main arm64 libgbm1 arm64 25.0.3-1ubuntu2 [33.7 kB] 175s Get:42 http://ftpmaster.internal/ubuntu questing/main arm64 libwayland-client0 arm64 1.23.1-3 [27.0 kB] 175s Get:43 http://ftpmaster.internal/ubuntu questing/main arm64 libxcb-shm0 arm64 1.17.0-2 [5884 B] 175s Get:44 http://ftpmaster.internal/ubuntu questing/main arm64 libegl-mesa0 arm64 25.0.3-1ubuntu2 [122 kB] 175s Get:45 http://ftpmaster.internal/ubuntu questing/main arm64 libfontenc1 arm64 1:1.1.8-1build1 [13.9 kB] 175s Get:46 http://ftpmaster.internal/ubuntu questing/main arm64 libvulkan1 arm64 1.4.309.0-1 [155 kB] 175s Get:47 http://ftpmaster.internal/ubuntu questing/main arm64 libgl1-mesa-dri arm64 25.0.3-1ubuntu2 [35.4 kB] 175s Get:48 http://ftpmaster.internal/ubuntu questing/main arm64 libxcb-glx0 arm64 1.17.0-2 [25.5 kB] 175s Get:49 http://ftpmaster.internal/ubuntu questing/main arm64 libxxf86vm1 arm64 1:1.1.4-1build4 [9130 B] 175s Get:50 http://ftpmaster.internal/ubuntu questing/main arm64 libglx-mesa0 arm64 25.0.3-1ubuntu2 [151 kB] 175s Get:51 http://ftpmaster.internal/ubuntu questing/main arm64 libgomp1 arm64 15.1.0-2ubuntu1 [147 kB] 175s Get:52 http://ftpmaster.internal/ubuntu questing/main arm64 libgraphite2-3 arm64 1.3.14-2ubuntu1 [70.6 kB] 175s Get:53 http://ftpmaster.internal/ubuntu questing/main arm64 libharfbuzz0b arm64 10.2.0-1 [490 kB] 175s Get:54 http://ftpmaster.internal/ubuntu questing/universe arm64 libsz2 arm64 1.1.3-1 [5254 B] 175s Get:55 http://ftpmaster.internal/ubuntu questing/universe arm64 libhdf5-310 arm64 1.14.5+repack-3 [1331 kB] 175s Get:56 http://ftpmaster.internal/ubuntu questing/main arm64 libice6 arm64 2:1.1.1-1 [42.3 kB] 175s Get:57 http://ftpmaster.internal/ubuntu questing/main arm64 libimagequant0 arm64 2.18.0-1build1 [37.1 kB] 175s Get:58 http://ftpmaster.internal/ubuntu questing/main arm64 libwacom-common all 2.14.0-1 [103 kB] 175s Get:59 http://ftpmaster.internal/ubuntu questing/main arm64 libwacom9 arm64 2.14.0-1 [26.7 kB] 175s Get:60 http://ftpmaster.internal/ubuntu questing/main arm64 libinput-bin arm64 1.28.1-1 [23.7 kB] 175s Get:61 http://ftpmaster.internal/ubuntu questing/main arm64 libmtdev1t64 arm64 1.1.7-1 [14.6 kB] 175s Get:62 http://ftpmaster.internal/ubuntu questing/main arm64 libinput10 arm64 1.28.1-1 [139 kB] 175s Get:63 http://ftpmaster.internal/ubuntu questing/main arm64 libjpeg-turbo8 arm64 2.1.5-3ubuntu2 [165 kB] 175s Get:64 http://ftpmaster.internal/ubuntu questing/main arm64 libjpeg8 arm64 8c-2ubuntu11 [2148 B] 176s Get:65 http://ftpmaster.internal/ubuntu questing/main arm64 libjs-jquery all 3.6.1+dfsg+~3.5.14-1 [328 kB] 176s Get:66 http://ftpmaster.internal/ubuntu questing/universe arm64 libjs-jquery-ui all 1.13.2+dfsg-1 [252 kB] 176s Get:67 http://ftpmaster.internal/ubuntu questing/universe arm64 liblbfgsb0 arm64 3.0+dfsg.4-1build1 [27.7 kB] 176s Get:68 http://ftpmaster.internal/ubuntu questing/main arm64 liblcms2-2 arm64 2.16-2 [170 kB] 176s Get:69 http://ftpmaster.internal/ubuntu questing/main arm64 liblerc4 arm64 4.0.0+ds-5ubuntu1 [167 kB] 176s Get:70 http://ftpmaster.internal/ubuntu questing/universe arm64 libmd4c0 arm64 0.5.2-2 [42.4 kB] 176s Get:71 http://ftpmaster.internal/ubuntu questing/main arm64 libpcre2-16-0 arm64 10.45-1 [222 kB] 176s Get:72 http://ftpmaster.internal/ubuntu questing/main arm64 libpixman-1-0 arm64 0.44.0-3 [197 kB] 176s Get:73 http://ftpmaster.internal/ubuntu questing/universe arm64 libqhull-r8.0 arm64 2020.2-6build1 [189 kB] 176s Get:74 http://ftpmaster.internal/ubuntu questing/universe arm64 libqt5core5t64 arm64 5.15.15+dfsg-4ubuntu1 [1999 kB] 176s Get:75 http://ftpmaster.internal/ubuntu questing/universe arm64 libqt5dbus5t64 arm64 5.15.15+dfsg-4ubuntu1 [222 kB] 176s Get:76 http://ftpmaster.internal/ubuntu questing/main arm64 libglvnd0 arm64 1.7.0-1build1 [60.6 kB] 176s Get:77 http://ftpmaster.internal/ubuntu questing/main arm64 libegl1 arm64 1.7.0-1build1 [29.5 kB] 176s Get:78 http://ftpmaster.internal/ubuntu questing/main arm64 libglx0 arm64 1.7.0-1build1 [33.2 kB] 176s Get:79 http://ftpmaster.internal/ubuntu questing/main arm64 libgl1 arm64 1.7.0-1build1 [106 kB] 176s Get:80 http://ftpmaster.internal/ubuntu questing/universe arm64 libqt5network5t64 arm64 5.15.15+dfsg-4ubuntu1 [735 kB] 176s Get:81 http://ftpmaster.internal/ubuntu questing/main arm64 libsm6 arm64 2:1.2.6-1 [16.6 kB] 176s Get:82 http://ftpmaster.internal/ubuntu questing/main arm64 libxcb-icccm4 arm64 0.4.2-1 [10.9 kB] 176s Get:83 http://ftpmaster.internal/ubuntu questing/main arm64 libxcb-util1 arm64 0.4.1-1 [10.9 kB] 176s Get:84 http://ftpmaster.internal/ubuntu questing/main arm64 libxcb-image0 arm64 0.4.0-2build1 [10.8 kB] 176s Get:85 http://ftpmaster.internal/ubuntu questing/main arm64 libxcb-keysyms1 arm64 0.4.1-1 [8802 B] 176s Get:86 http://ftpmaster.internal/ubuntu questing/main arm64 libxcb-render0 arm64 1.17.0-2 [16.6 kB] 176s Get:87 http://ftpmaster.internal/ubuntu questing/main arm64 libxcb-render-util0 arm64 0.3.10-1 [10.5 kB] 176s Get:88 http://ftpmaster.internal/ubuntu questing/main arm64 libxcb-shape0 arm64 1.17.0-2 [6246 B] 176s Get:89 http://ftpmaster.internal/ubuntu questing/main arm64 libxcb-xinerama0 arm64 1.17.0-2 [5590 B] 176s Get:90 http://ftpmaster.internal/ubuntu questing/main arm64 libxcb-xinput0 arm64 1.17.0-2 [34.2 kB] 176s Get:91 http://ftpmaster.internal/ubuntu questing/main arm64 libxcb-xkb1 arm64 1.17.0-2 [32.5 kB] 176s Get:92 http://ftpmaster.internal/ubuntu questing/main arm64 libxkbcommon-x11-0 arm64 1.7.0-2 [13.8 kB] 176s Get:93 http://ftpmaster.internal/ubuntu questing/universe arm64 libqt5gui5t64 arm64 5.15.15+dfsg-4ubuntu1 [3680 kB] 176s Get:94 http://ftpmaster.internal/ubuntu questing/universe arm64 libqt5widgets5t64 arm64 5.15.15+dfsg-4ubuntu1 [2568 kB] 176s Get:95 http://ftpmaster.internal/ubuntu questing/universe arm64 libqt5xml5t64 arm64 5.15.15+dfsg-4ubuntu1 [124 kB] 176s Get:96 http://ftpmaster.internal/ubuntu questing/universe arm64 libqt5designer5 arm64 5.15.15-6build1 [2840 kB] 176s Get:97 http://ftpmaster.internal/ubuntu questing/universe arm64 libqt5sql5t64 arm64 5.15.15+dfsg-4ubuntu1 [123 kB] 176s Get:98 http://ftpmaster.internal/ubuntu questing/universe arm64 libqt5help5 arm64 5.15.15-6build1 [165 kB] 176s Get:99 http://ftpmaster.internal/ubuntu questing/universe arm64 libqt5printsupport5t64 arm64 5.15.15+dfsg-4ubuntu1 [209 kB] 176s Get:100 http://ftpmaster.internal/ubuntu questing/universe arm64 libqt5test5t64 arm64 5.15.15+dfsg-4ubuntu1 [144 kB] 176s Get:101 http://ftpmaster.internal/ubuntu questing/main arm64 libraqm0 arm64 0.10.2-1 [14.9 kB] 176s Get:102 http://ftpmaster.internal/ubuntu questing/main arm64 libsharpyuv0 arm64 1.5.0-0.1 [16.9 kB] 176s Get:103 http://ftpmaster.internal/ubuntu questing/main arm64 libjbig0 arm64 2.1-6.1ubuntu2 [29.3 kB] 176s Get:104 http://ftpmaster.internal/ubuntu questing/main arm64 libwebp7 arm64 1.5.0-0.1 [194 kB] 177s Get:105 http://ftpmaster.internal/ubuntu questing/main arm64 libtiff6 arm64 4.7.0-3ubuntu1 [197 kB] 177s Get:106 http://ftpmaster.internal/ubuntu questing/main arm64 libwebpdemux2 arm64 1.5.0-0.1 [12.5 kB] 177s Get:107 http://ftpmaster.internal/ubuntu questing/main arm64 libwebpmux3 arm64 1.5.0-0.1 [25.4 kB] 177s Get:108 http://ftpmaster.internal/ubuntu questing/main arm64 libxt6t64 arm64 1:1.2.1-1.2build1 [168 kB] 177s Get:109 http://ftpmaster.internal/ubuntu questing/main arm64 libxmu6 arm64 2:1.1.3-3build2 [47.5 kB] 177s Get:110 http://ftpmaster.internal/ubuntu questing/main arm64 libxpm4 arm64 1:3.5.17-1build2 [35.1 kB] 177s Get:111 http://ftpmaster.internal/ubuntu questing/main arm64 libxaw7 arm64 2:1.0.16-1 [184 kB] 177s Get:112 http://ftpmaster.internal/ubuntu questing/main arm64 libxfont2 arm64 1:2.0.6-1build1 [88.7 kB] 177s Get:113 http://ftpmaster.internal/ubuntu questing/main arm64 libxkbfile1 arm64 1:1.1.0-1build4 [69.4 kB] 177s Get:114 http://ftpmaster.internal/ubuntu questing/main arm64 libxrandr2 arm64 2:1.5.4-1 [19.6 kB] 177s Get:115 http://ftpmaster.internal/ubuntu questing/main arm64 libxslt1.1 arm64 1.1.39-0exp1ubuntu4 [168 kB] 177s Get:116 http://ftpmaster.internal/ubuntu questing/universe arm64 libzopfli1 arm64 1.0.3-3 [108 kB] 177s Get:117 http://ftpmaster.internal/ubuntu questing-proposed/universe arm64 python-matplotlib-data all 3.10.1+dfsg1-3 [2936 kB] 177s Get:118 http://ftpmaster.internal/ubuntu questing/universe arm64 python-tables-data all 3.10.2-2build1 [49.7 kB] 177s Get:119 http://ftpmaster.internal/ubuntu questing/main arm64 python3-all arm64 3.13.3-1 [880 B] 177s Get:120 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-async-generator all 1.10-4 [17.5 kB] 177s Get:121 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-bottleneck arm64 1.4.2+ds1-2build1 [82.9 kB] 177s Get:122 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-brotli arm64 1.1.0-2build4 [342 kB] 177s Get:123 http://ftpmaster.internal/ubuntu questing/main arm64 python3-soupsieve all 2.7-1 [33.5 kB] 177s Get:124 http://ftpmaster.internal/ubuntu questing/main arm64 python3-bs4 all 4.13.4-1 [137 kB] 177s Get:125 http://ftpmaster.internal/ubuntu questing/main arm64 python3-click all 8.2.0+0.really.8.1.8-1 [80.0 kB] 177s Get:126 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-cloudpickle all 3.1.1-1 [22.4 kB] 177s Get:127 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-contourpy arm64 1.3.1-1build1 [182 kB] 177s Get:128 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-cpuinfo all 9.0.0+git20221119-3 [21.7 kB] 177s Get:129 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-cycler all 0.12.1-1 [9716 B] 177s Get:130 http://ftpmaster.internal/ubuntu questing-proposed/universe arm64 python3-fsspec all 2025.3.2-1 [217 kB] 177s Get:131 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-toolz all 1.0.0-2 [45.0 kB] 177s Get:132 http://ftpmaster.internal/ubuntu questing/main arm64 python3-packaging all 25.0-1 [52.8 kB] 177s Get:133 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-locket all 1.0.0-2 [5872 B] 177s Get:134 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-partd all 1.4.2-1 [15.7 kB] 177s Get:135 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-dask all 2024.12.1+dfsg-2 [875 kB] 177s Get:136 http://ftpmaster.internal/ubuntu questing/main arm64 python3-decorator all 5.2.1-2 [28.1 kB] 177s Get:137 http://ftpmaster.internal/ubuntu questing/main arm64 python3-defusedxml all 0.7.1-3 [42.2 kB] 177s Get:138 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-et-xmlfile all 2.0.0-1 [79.4 kB] 177s Get:139 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-execnet all 2.1.1-1 [33.4 kB] 177s Get:140 http://ftpmaster.internal/ubuntu questing/main arm64 python3-platformdirs all 4.3.7-1 [16.9 kB] 177s Get:141 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-fs all 2.4.16-7 [90.8 kB] 177s Get:142 http://ftpmaster.internal/ubuntu questing/main arm64 python3-lxml arm64 5.4.0-1 [1256 kB] 177s Get:143 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-lz4 arm64 4.4.0+dfsg-2 [27.1 kB] 177s Get:144 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-scipy arm64 1.14.1-4ubuntu2 [16.7 MB] 178s Get:145 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-mpmath all 1.3.0-1 [425 kB] 178s Get:146 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-sympy all 1.13.3-5 [4229 kB] 178s Get:147 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-ufolib2 all 0.17.1+dfsg1-1 [33.5 kB] 178s Get:148 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-zopfli arm64 0.2.3.post1-1 [10.7 kB] 178s Get:149 http://ftpmaster.internal/ubuntu questing/universe arm64 unicode-data all 15.1.0-1 [8878 kB] 179s Get:150 http://ftpmaster.internal/ubuntu questing-proposed/universe arm64 python3-fonttools arm64 4.57.0-1 [1453 kB] 179s Get:151 http://ftpmaster.internal/ubuntu questing/main arm64 python3-webencodings all 0.5.1-5 [11.5 kB] 179s Get:152 http://ftpmaster.internal/ubuntu questing/main arm64 python3-html5lib all 1.2-2 [90.6 kB] 179s Get:153 http://ftpmaster.internal/ubuntu questing/main arm64 python3-sortedcontainers all 2.4.0-2 [27.6 kB] 179s Get:154 http://ftpmaster.internal/ubuntu questing-proposed/universe arm64 python3-hypothesis all 6.130.5-1 [341 kB] 179s Get:155 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-iniconfig all 1.1.1-2 [6024 B] 179s Get:156 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-kiwisolver arm64 1.4.7-3build1 [50.7 kB] 179s Get:157 http://ftpmaster.internal/ubuntu questing/main arm64 libopenjp2-7 arm64 2.5.3-2 [183 kB] 179s Get:158 http://ftpmaster.internal/ubuntu questing/main arm64 python3-pil arm64 11.1.0-5build1 [463 kB] 179s Get:159 http://ftpmaster.internal/ubuntu questing-proposed/main arm64 python3.13-tk arm64 3.13.3-2 [106 kB] 179s Get:160 http://ftpmaster.internal/ubuntu questing/main arm64 python3-tk arm64 3.13.3-1 [9856 B] 179s Get:161 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-pil.imagetk arm64 11.1.0-5build1 [9892 B] 179s Get:162 http://ftpmaster.internal/ubuntu questing-proposed/universe arm64 python3-matplotlib arm64 3.10.1+dfsg1-3 [18.0 MB] 180s Get:163 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-numexpr arm64 2.10.2-1build2 [120 kB] 180s Get:164 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-odf all 1.4.2-4 [79.0 kB] 180s Get:165 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-openpyxl all 3.1.5+dfsg-2 [152 kB] 180s Get:166 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-pluggy all 1.5.0-1 [21.0 kB] 180s Get:167 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-py all 1.11.0-4 [72.7 kB] 180s Get:168 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-pyqt5.sip arm64 12.17.0-1build1 [67.6 kB] 180s Get:169 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-pyqt5 arm64 5.15.11+dfsg-2 [2580 kB] 180s Get:170 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-pyreadstat arm64 1.2.8-1build1 [358 kB] 180s Get:171 http://ftpmaster.internal/ubuntu questing-proposed/universe arm64 python3-pytest all 8.3.5-2 [252 kB] 180s Get:172 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-pytest-asyncio all 0.25.1-1 [17.0 kB] 180s Get:173 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-pytest-forked all 1.6.0-3 [7470 B] 180s Get:174 http://ftpmaster.internal/ubuntu questing/main arm64 python3-werkzeug all 3.1.3-2 [169 kB] 180s Get:175 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-pytest-localserver all 0.9.0.post0-1 [21.9 kB] 180s Get:176 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-pytest-xdist all 3.6.1-1 [33.8 kB] 180s Get:177 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-pytestqt all 4.4.0-1 [32.4 kB] 180s Get:178 http://ftpmaster.internal/ubuntu questing-proposed/main arm64 python3-pytz all 2025.2-2 [163 kB] 180s Get:179 http://ftpmaster.internal/ubuntu questing/main arm64 python3-greenlet arm64 3.1.0-1build1 [160 kB] 180s Get:180 http://ftpmaster.internal/ubuntu questing/main arm64 python3-sqlalchemy all 2.0.38+ds1-0ubuntu2 [1215 kB] 180s Get:181 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-tables-lib arm64 3.10.2-2build1 [510 kB] 180s Get:182 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-tables all 3.10.2-2build1 [354 kB] 180s Get:183 http://ftpmaster.internal/ubuntu questing/main arm64 python3-tabulate all 0.9.0-1 [45.3 kB] 180s Get:184 http://ftpmaster.internal/ubuntu questing-proposed/main arm64 python3-tz all 2025.2-2 [1860 B] 180s Get:185 http://ftpmaster.internal/ubuntu questing-proposed/universe arm64 python3-xarray all 2025.03.1-8 [831 kB] 180s Get:186 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-xlrd all 2.0.1-2 [83.1 kB] 180s Get:187 http://ftpmaster.internal/ubuntu questing/universe arm64 python3-xlsxwriter all 3.1.9-2 [462 kB] 180s Get:188 http://ftpmaster.internal/ubuntu questing-proposed/universe arm64 python3-zstandard arm64 0.23.0-4 [360 kB] 180s Get:189 http://ftpmaster.internal/ubuntu questing-proposed/main arm64 python3.13-gdbm arm64 3.13.3-2 [31.5 kB] 180s Get:190 http://ftpmaster.internal/ubuntu questing-proposed/main arm64 tzdata-legacy all 2025b-3ubuntu1 [99.3 kB] 180s Get:191 http://ftpmaster.internal/ubuntu questing/main arm64 x11-xkb-utils arm64 7.7+9 [165 kB] 180s Get:192 http://ftpmaster.internal/ubuntu questing/universe arm64 xsel arm64 1.2.1-1 [20.1 kB] 180s Get:193 http://ftpmaster.internal/ubuntu questing/main arm64 xserver-common all 2:21.1.16-1ubuntu1 [34.4 kB] 180s Get:194 http://ftpmaster.internal/ubuntu questing/universe arm64 xvfb arm64 2:21.1.16-1ubuntu1 [870 kB] 180s Get:195 http://ftpmaster.internal/ubuntu questing-proposed/main arm64 zstd arm64 1.5.7+dfsg-1 [607 kB] 180s Get:196 http://ftpmaster.internal/ubuntu questing/universe arm64 locales-all arm64 2.41-6ubuntu1 [11.2 MB] 182s Preconfiguring packages ... 182s Fetched 122 MB in 8s (16.0 MB/s) 182s (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 ... 121138 files and directories currently installed.) 182s Preparing to unpack .../0-python3.13_3.13.3-2_arm64.deb ... 182s Unpacking python3.13 (3.13.3-2) over (3.13.3-1) ... 182s Preparing to unpack .../1-libpython3.13_3.13.3-2_arm64.deb ... 182s Unpacking libpython3.13:arm64 (3.13.3-2) over (3.13.3-1) ... 182s Preparing to unpack .../2-libpython3.13-stdlib_3.13.3-2_arm64.deb ... 182s Unpacking libpython3.13-stdlib:arm64 (3.13.3-2) over (3.13.3-1) ... 182s Preparing to unpack .../3-python3.13-minimal_3.13.3-2_arm64.deb ... 182s Unpacking python3.13-minimal (3.13.3-2) over (3.13.3-1) ... 182s Preparing to unpack .../4-libpython3.13-minimal_3.13.3-2_arm64.deb ... 182s Unpacking libpython3.13-minimal:arm64 (3.13.3-2) over (3.13.3-1) ... 183s Preparing to unpack .../5-tzdata_2025b-3ubuntu1_all.deb ... 183s Unpacking tzdata (2025b-3ubuntu1) over (2025b-1ubuntu1) ... 183s Preparing to unpack .../6-libzstd1_1.5.7+dfsg-1_arm64.deb ... 183s Unpacking libzstd1:arm64 (1.5.7+dfsg-1) over (1.5.6+dfsg-2) ... 183s Setting up libzstd1:arm64 (1.5.7+dfsg-1) ... 183s Selecting previously unselected package libtcl8.6:arm64. 183s (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 ... 121138 files and directories currently installed.) 183s Preparing to unpack .../000-libtcl8.6_8.6.16+dfsg-1_arm64.deb ... 183s Unpacking libtcl8.6:arm64 (8.6.16+dfsg-1) ... 183s Selecting previously unselected package fonts-dejavu-mono. 183s Preparing to unpack .../001-fonts-dejavu-mono_2.37-8_all.deb ... 183s Unpacking fonts-dejavu-mono (2.37-8) ... 183s Selecting previously unselected package fonts-dejavu-core. 183s Preparing to unpack .../002-fonts-dejavu-core_2.37-8_all.deb ... 183s Unpacking fonts-dejavu-core (2.37-8) ... 183s Selecting previously unselected package fontconfig-config. 183s Preparing to unpack .../003-fontconfig-config_2.15.0-2.2ubuntu1_arm64.deb ... 183s Unpacking fontconfig-config (2.15.0-2.2ubuntu1) ... 183s Selecting previously unselected package libfontconfig1:arm64. 183s Preparing to unpack .../004-libfontconfig1_2.15.0-2.2ubuntu1_arm64.deb ... 183s Unpacking libfontconfig1:arm64 (2.15.0-2.2ubuntu1) ... 183s Selecting previously unselected package libxrender1:arm64. 183s Preparing to unpack .../005-libxrender1_1%3a0.9.12-1_arm64.deb ... 183s Unpacking libxrender1:arm64 (1:0.9.12-1) ... 183s Selecting previously unselected package libxft2:arm64. 183s Preparing to unpack .../006-libxft2_2.3.6-1build1_arm64.deb ... 183s Unpacking libxft2:arm64 (2.3.6-1build1) ... 183s Selecting previously unselected package x11-common. 183s Preparing to unpack .../007-x11-common_1%3a7.7+23ubuntu4_all.deb ... 183s Unpacking x11-common (1:7.7+23ubuntu4) ... 183s Selecting previously unselected package libxss1:arm64. 183s Preparing to unpack .../008-libxss1_1%3a1.2.3-1build3_arm64.deb ... 183s Unpacking libxss1:arm64 (1:1.2.3-1build3) ... 183s Selecting previously unselected package libtk8.6:arm64. 183s Preparing to unpack .../009-libtk8.6_8.6.16-1_arm64.deb ... 183s Unpacking libtk8.6:arm64 (8.6.16-1) ... 183s Selecting previously unselected package tk8.6-blt2.5. 183s Preparing to unpack .../010-tk8.6-blt2.5_2.5.3+dfsg-8_arm64.deb ... 183s Unpacking tk8.6-blt2.5 (2.5.3+dfsg-8) ... 183s Selecting previously unselected package blt. 183s Preparing to unpack .../011-blt_2.5.3+dfsg-8_arm64.deb ... 183s Unpacking blt (2.5.3+dfsg-8) ... 184s Selecting previously unselected package fontconfig. 184s Preparing to unpack .../012-fontconfig_2.15.0-2.2ubuntu1_arm64.deb ... 184s Unpacking fontconfig (2.15.0-2.2ubuntu1) ... 184s Selecting previously unselected package fonts-lyx. 184s Preparing to unpack .../013-fonts-lyx_2.4.3-1_all.deb ... 184s Unpacking fonts-lyx (2.4.3-1) ... 184s Selecting previously unselected package libaec0:arm64. 184s Preparing to unpack .../014-libaec0_1.1.3-1_arm64.deb ... 184s Unpacking libaec0:arm64 (1.1.3-1) ... 184s Selecting previously unselected package libavahi-common-data:arm64. 184s Preparing to unpack .../015-libavahi-common-data_0.8-16ubuntu2_arm64.deb ... 184s Unpacking libavahi-common-data:arm64 (0.8-16ubuntu2) ... 184s Selecting previously unselected package libavahi-common3:arm64. 184s Preparing to unpack .../016-libavahi-common3_0.8-16ubuntu2_arm64.deb ... 184s Unpacking libavahi-common3:arm64 (0.8-16ubuntu2) ... 184s Selecting previously unselected package libavahi-client3:arm64. 184s Preparing to unpack .../017-libavahi-client3_0.8-16ubuntu2_arm64.deb ... 184s Unpacking libavahi-client3:arm64 (0.8-16ubuntu2) ... 184s Selecting previously unselected package libsnappy1v5:arm64. 184s Preparing to unpack .../018-libsnappy1v5_1.2.2-1_arm64.deb ... 184s Unpacking libsnappy1v5:arm64 (1.2.2-1) ... 184s Selecting previously unselected package libblosc1:arm64. 184s Preparing to unpack .../019-libblosc1_1.21.5+ds-1build1_arm64.deb ... 184s Unpacking libblosc1:arm64 (1.21.5+ds-1build1) ... 184s Selecting previously unselected package libblosc2-4:arm64. 184s Preparing to unpack .../020-libblosc2-4_2.17.1+ds-1_arm64.deb ... 184s Unpacking libblosc2-4:arm64 (2.17.1+ds-1) ... 184s Selecting previously unselected package libcups2t64:arm64. 184s Preparing to unpack .../021-libcups2t64_2.4.12-0ubuntu1_arm64.deb ... 184s Unpacking libcups2t64:arm64 (2.4.12-0ubuntu1) ... 184s Selecting previously unselected package libdeflate0:arm64. 184s Preparing to unpack .../022-libdeflate0_1.23-2_arm64.deb ... 184s Unpacking libdeflate0:arm64 (1.23-2) ... 184s Selecting previously unselected package libdouble-conversion3:arm64. 184s Preparing to unpack .../023-libdouble-conversion3_3.3.1-1_arm64.deb ... 184s Unpacking libdouble-conversion3:arm64 (3.3.1-1) ... 184s Selecting previously unselected package libwayland-server0:arm64. 184s Preparing to unpack .../024-libwayland-server0_1.23.1-3_arm64.deb ... 184s Unpacking libwayland-server0:arm64 (1.23.1-3) ... 184s Selecting previously unselected package libx11-xcb1:arm64. 184s Preparing to unpack .../025-libx11-xcb1_2%3a1.8.12-1_arm64.deb ... 184s Unpacking libx11-xcb1:arm64 (2:1.8.12-1) ... 184s Selecting previously unselected package libxcb-dri3-0:arm64. 184s Preparing to unpack .../026-libxcb-dri3-0_1.17.0-2_arm64.deb ... 184s Unpacking libxcb-dri3-0:arm64 (1.17.0-2) ... 184s Selecting previously unselected package libxcb-present0:arm64. 184s Preparing to unpack .../027-libxcb-present0_1.17.0-2_arm64.deb ... 184s Unpacking libxcb-present0:arm64 (1.17.0-2) ... 184s Selecting previously unselected package libxcb-randr0:arm64. 184s Preparing to unpack .../028-libxcb-randr0_1.17.0-2_arm64.deb ... 184s Unpacking libxcb-randr0:arm64 (1.17.0-2) ... 184s Selecting previously unselected package libxcb-sync1:arm64. 184s Preparing to unpack .../029-libxcb-sync1_1.17.0-2_arm64.deb ... 184s Unpacking libxcb-sync1:arm64 (1.17.0-2) ... 184s Selecting previously unselected package libxcb-xfixes0:arm64. 184s Preparing to unpack .../030-libxcb-xfixes0_1.17.0-2_arm64.deb ... 184s Unpacking libxcb-xfixes0:arm64 (1.17.0-2) ... 184s Selecting previously unselected package libxshmfence1:arm64. 184s Preparing to unpack .../031-libxshmfence1_1.3.3-1_arm64.deb ... 184s Unpacking libxshmfence1:arm64 (1.3.3-1) ... 184s Selecting previously unselected package mesa-libgallium:arm64. 184s Preparing to unpack .../032-mesa-libgallium_25.0.3-1ubuntu2_arm64.deb ... 184s Unpacking mesa-libgallium:arm64 (25.0.3-1ubuntu2) ... 185s Selecting previously unselected package libgbm1:arm64. 185s Preparing to unpack .../033-libgbm1_25.0.3-1ubuntu2_arm64.deb ... 185s Unpacking libgbm1:arm64 (25.0.3-1ubuntu2) ... 185s Selecting previously unselected package libwayland-client0:arm64. 185s Preparing to unpack .../034-libwayland-client0_1.23.1-3_arm64.deb ... 185s Unpacking libwayland-client0:arm64 (1.23.1-3) ... 185s Selecting previously unselected package libxcb-shm0:arm64. 185s Preparing to unpack .../035-libxcb-shm0_1.17.0-2_arm64.deb ... 185s Unpacking libxcb-shm0:arm64 (1.17.0-2) ... 185s Selecting previously unselected package libegl-mesa0:arm64. 185s Preparing to unpack .../036-libegl-mesa0_25.0.3-1ubuntu2_arm64.deb ... 185s Unpacking libegl-mesa0:arm64 (25.0.3-1ubuntu2) ... 185s Selecting previously unselected package libfontenc1:arm64. 185s Preparing to unpack .../037-libfontenc1_1%3a1.1.8-1build1_arm64.deb ... 185s Unpacking libfontenc1:arm64 (1:1.1.8-1build1) ... 185s Selecting previously unselected package libvulkan1:arm64. 185s Preparing to unpack .../038-libvulkan1_1.4.309.0-1_arm64.deb ... 185s Unpacking libvulkan1:arm64 (1.4.309.0-1) ... 185s Selecting previously unselected package libgl1-mesa-dri:arm64. 185s Preparing to unpack .../039-libgl1-mesa-dri_25.0.3-1ubuntu2_arm64.deb ... 185s Unpacking libgl1-mesa-dri:arm64 (25.0.3-1ubuntu2) ... 185s Selecting previously unselected package libxcb-glx0:arm64. 185s Preparing to unpack .../040-libxcb-glx0_1.17.0-2_arm64.deb ... 185s Unpacking libxcb-glx0:arm64 (1.17.0-2) ... 185s Selecting previously unselected package libxxf86vm1:arm64. 185s Preparing to unpack .../041-libxxf86vm1_1%3a1.1.4-1build4_arm64.deb ... 185s Unpacking libxxf86vm1:arm64 (1:1.1.4-1build4) ... 185s Selecting previously unselected package libglx-mesa0:arm64. 185s Preparing to unpack .../042-libglx-mesa0_25.0.3-1ubuntu2_arm64.deb ... 185s Unpacking libglx-mesa0:arm64 (25.0.3-1ubuntu2) ... 185s Selecting previously unselected package libgomp1:arm64. 185s Preparing to unpack .../043-libgomp1_15.1.0-2ubuntu1_arm64.deb ... 185s Unpacking libgomp1:arm64 (15.1.0-2ubuntu1) ... 185s Selecting previously unselected package libgraphite2-3:arm64. 185s Preparing to unpack .../044-libgraphite2-3_1.3.14-2ubuntu1_arm64.deb ... 185s Unpacking libgraphite2-3:arm64 (1.3.14-2ubuntu1) ... 185s Selecting previously unselected package libharfbuzz0b:arm64. 185s Preparing to unpack .../045-libharfbuzz0b_10.2.0-1_arm64.deb ... 185s Unpacking libharfbuzz0b:arm64 (10.2.0-1) ... 185s Selecting previously unselected package libsz2:arm64. 185s Preparing to unpack .../046-libsz2_1.1.3-1_arm64.deb ... 185s Unpacking libsz2:arm64 (1.1.3-1) ... 185s Selecting previously unselected package libhdf5-310:arm64. 185s Preparing to unpack .../047-libhdf5-310_1.14.5+repack-3_arm64.deb ... 185s Unpacking libhdf5-310:arm64 (1.14.5+repack-3) ... 185s Selecting previously unselected package libice6:arm64. 185s Preparing to unpack .../048-libice6_2%3a1.1.1-1_arm64.deb ... 185s Unpacking libice6:arm64 (2:1.1.1-1) ... 185s Selecting previously unselected package libimagequant0:arm64. 185s Preparing to unpack .../049-libimagequant0_2.18.0-1build1_arm64.deb ... 185s Unpacking libimagequant0:arm64 (2.18.0-1build1) ... 185s Selecting previously unselected package libwacom-common. 185s Preparing to unpack .../050-libwacom-common_2.14.0-1_all.deb ... 185s Unpacking libwacom-common (2.14.0-1) ... 185s Selecting previously unselected package libwacom9:arm64. 185s Preparing to unpack .../051-libwacom9_2.14.0-1_arm64.deb ... 185s Unpacking libwacom9:arm64 (2.14.0-1) ... 185s Selecting previously unselected package libinput-bin. 186s Preparing to unpack .../052-libinput-bin_1.28.1-1_arm64.deb ... 186s Unpacking libinput-bin (1.28.1-1) ... 186s Selecting previously unselected package libmtdev1t64:arm64. 186s Preparing to unpack .../053-libmtdev1t64_1.1.7-1_arm64.deb ... 186s Unpacking libmtdev1t64:arm64 (1.1.7-1) ... 186s Selecting previously unselected package libinput10:arm64. 186s Preparing to unpack .../054-libinput10_1.28.1-1_arm64.deb ... 186s Unpacking libinput10:arm64 (1.28.1-1) ... 186s Selecting previously unselected package libjpeg-turbo8:arm64. 186s Preparing to unpack .../055-libjpeg-turbo8_2.1.5-3ubuntu2_arm64.deb ... 186s Unpacking libjpeg-turbo8:arm64 (2.1.5-3ubuntu2) ... 186s Selecting previously unselected package libjpeg8:arm64. 186s Preparing to unpack .../056-libjpeg8_8c-2ubuntu11_arm64.deb ... 186s Unpacking libjpeg8:arm64 (8c-2ubuntu11) ... 186s Selecting previously unselected package libjs-jquery. 186s Preparing to unpack .../057-libjs-jquery_3.6.1+dfsg+~3.5.14-1_all.deb ... 186s Unpacking libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 186s Selecting previously unselected package libjs-jquery-ui. 186s Preparing to unpack .../058-libjs-jquery-ui_1.13.2+dfsg-1_all.deb ... 186s Unpacking libjs-jquery-ui (1.13.2+dfsg-1) ... 186s Selecting previously unselected package liblbfgsb0:arm64. 186s Preparing to unpack .../059-liblbfgsb0_3.0+dfsg.4-1build1_arm64.deb ... 186s Unpacking liblbfgsb0:arm64 (3.0+dfsg.4-1build1) ... 186s Selecting previously unselected package liblcms2-2:arm64. 186s Preparing to unpack .../060-liblcms2-2_2.16-2_arm64.deb ... 186s Unpacking liblcms2-2:arm64 (2.16-2) ... 186s Selecting previously unselected package liblerc4:arm64. 186s Preparing to unpack .../061-liblerc4_4.0.0+ds-5ubuntu1_arm64.deb ... 186s Unpacking liblerc4:arm64 (4.0.0+ds-5ubuntu1) ... 186s Selecting previously unselected package libmd4c0:arm64. 186s Preparing to unpack .../062-libmd4c0_0.5.2-2_arm64.deb ... 186s Unpacking libmd4c0:arm64 (0.5.2-2) ... 186s Selecting previously unselected package libpcre2-16-0:arm64. 186s Preparing to unpack .../063-libpcre2-16-0_10.45-1_arm64.deb ... 186s Unpacking libpcre2-16-0:arm64 (10.45-1) ... 186s Selecting previously unselected package libpixman-1-0:arm64. 186s Preparing to unpack .../064-libpixman-1-0_0.44.0-3_arm64.deb ... 186s Unpacking libpixman-1-0:arm64 (0.44.0-3) ... 186s Selecting previously unselected package libqhull-r8.0:arm64. 186s Preparing to unpack .../065-libqhull-r8.0_2020.2-6build1_arm64.deb ... 186s Unpacking libqhull-r8.0:arm64 (2020.2-6build1) ... 186s Selecting previously unselected package libqt5core5t64:arm64. 186s Preparing to unpack .../066-libqt5core5t64_5.15.15+dfsg-4ubuntu1_arm64.deb ... 186s Unpacking libqt5core5t64:arm64 (5.15.15+dfsg-4ubuntu1) ... 186s Selecting previously unselected package libqt5dbus5t64:arm64. 186s Preparing to unpack .../067-libqt5dbus5t64_5.15.15+dfsg-4ubuntu1_arm64.deb ... 186s Unpacking libqt5dbus5t64:arm64 (5.15.15+dfsg-4ubuntu1) ... 186s Selecting previously unselected package libglvnd0:arm64. 186s Preparing to unpack .../068-libglvnd0_1.7.0-1build1_arm64.deb ... 186s Unpacking libglvnd0:arm64 (1.7.0-1build1) ... 186s Selecting previously unselected package libegl1:arm64. 186s Preparing to unpack .../069-libegl1_1.7.0-1build1_arm64.deb ... 186s Unpacking libegl1:arm64 (1.7.0-1build1) ... 186s Selecting previously unselected package libglx0:arm64. 186s Preparing to unpack .../070-libglx0_1.7.0-1build1_arm64.deb ... 186s Unpacking libglx0:arm64 (1.7.0-1build1) ... 186s Selecting previously unselected package libgl1:arm64. 186s Preparing to unpack .../071-libgl1_1.7.0-1build1_arm64.deb ... 186s Unpacking libgl1:arm64 (1.7.0-1build1) ... 186s Selecting previously unselected package libqt5network5t64:arm64. 186s Preparing to unpack .../072-libqt5network5t64_5.15.15+dfsg-4ubuntu1_arm64.deb ... 186s Unpacking libqt5network5t64:arm64 (5.15.15+dfsg-4ubuntu1) ... 186s Selecting previously unselected package libsm6:arm64. 187s Preparing to unpack .../073-libsm6_2%3a1.2.6-1_arm64.deb ... 187s Unpacking libsm6:arm64 (2:1.2.6-1) ... 187s Selecting previously unselected package libxcb-icccm4:arm64. 187s Preparing to unpack .../074-libxcb-icccm4_0.4.2-1_arm64.deb ... 187s Unpacking libxcb-icccm4:arm64 (0.4.2-1) ... 187s Selecting previously unselected package libxcb-util1:arm64. 187s Preparing to unpack .../075-libxcb-util1_0.4.1-1_arm64.deb ... 187s Unpacking libxcb-util1:arm64 (0.4.1-1) ... 187s Selecting previously unselected package libxcb-image0:arm64. 187s Preparing to unpack .../076-libxcb-image0_0.4.0-2build1_arm64.deb ... 187s Unpacking libxcb-image0:arm64 (0.4.0-2build1) ... 187s Selecting previously unselected package libxcb-keysyms1:arm64. 187s Preparing to unpack .../077-libxcb-keysyms1_0.4.1-1_arm64.deb ... 187s Unpacking libxcb-keysyms1:arm64 (0.4.1-1) ... 187s Selecting previously unselected package libxcb-render0:arm64. 187s Preparing to unpack .../078-libxcb-render0_1.17.0-2_arm64.deb ... 187s Unpacking libxcb-render0:arm64 (1.17.0-2) ... 187s Selecting previously unselected package libxcb-render-util0:arm64. 187s Preparing to unpack .../079-libxcb-render-util0_0.3.10-1_arm64.deb ... 187s Unpacking libxcb-render-util0:arm64 (0.3.10-1) ... 187s Selecting previously unselected package libxcb-shape0:arm64. 187s Preparing to unpack .../080-libxcb-shape0_1.17.0-2_arm64.deb ... 187s Unpacking libxcb-shape0:arm64 (1.17.0-2) ... 187s Selecting previously unselected package libxcb-xinerama0:arm64. 187s Preparing to unpack .../081-libxcb-xinerama0_1.17.0-2_arm64.deb ... 187s Unpacking libxcb-xinerama0:arm64 (1.17.0-2) ... 187s Selecting previously unselected package libxcb-xinput0:arm64. 187s Preparing to unpack .../082-libxcb-xinput0_1.17.0-2_arm64.deb ... 187s Unpacking libxcb-xinput0:arm64 (1.17.0-2) ... 187s Selecting previously unselected package libxcb-xkb1:arm64. 187s Preparing to unpack .../083-libxcb-xkb1_1.17.0-2_arm64.deb ... 187s Unpacking libxcb-xkb1:arm64 (1.17.0-2) ... 187s Selecting previously unselected package libxkbcommon-x11-0:arm64. 187s Preparing to unpack .../084-libxkbcommon-x11-0_1.7.0-2_arm64.deb ... 187s Unpacking libxkbcommon-x11-0:arm64 (1.7.0-2) ... 187s Selecting previously unselected package libqt5gui5t64:arm64. 187s Preparing to unpack .../085-libqt5gui5t64_5.15.15+dfsg-4ubuntu1_arm64.deb ... 187s Unpacking libqt5gui5t64:arm64 (5.15.15+dfsg-4ubuntu1) ... 187s Selecting previously unselected package libqt5widgets5t64:arm64. 187s Preparing to unpack .../086-libqt5widgets5t64_5.15.15+dfsg-4ubuntu1_arm64.deb ... 187s Unpacking libqt5widgets5t64:arm64 (5.15.15+dfsg-4ubuntu1) ... 187s Selecting previously unselected package libqt5xml5t64:arm64. 187s Preparing to unpack .../087-libqt5xml5t64_5.15.15+dfsg-4ubuntu1_arm64.deb ... 187s Unpacking libqt5xml5t64:arm64 (5.15.15+dfsg-4ubuntu1) ... 187s Selecting previously unselected package libqt5designer5:arm64. 187s Preparing to unpack .../088-libqt5designer5_5.15.15-6build1_arm64.deb ... 187s Unpacking libqt5designer5:arm64 (5.15.15-6build1) ... 187s Selecting previously unselected package libqt5sql5t64:arm64. 187s Preparing to unpack .../089-libqt5sql5t64_5.15.15+dfsg-4ubuntu1_arm64.deb ... 187s Unpacking libqt5sql5t64:arm64 (5.15.15+dfsg-4ubuntu1) ... 187s Selecting previously unselected package libqt5help5:arm64. 187s Preparing to unpack .../090-libqt5help5_5.15.15-6build1_arm64.deb ... 187s Unpacking libqt5help5:arm64 (5.15.15-6build1) ... 187s Selecting previously unselected package libqt5printsupport5t64:arm64. 187s Preparing to unpack .../091-libqt5printsupport5t64_5.15.15+dfsg-4ubuntu1_arm64.deb ... 187s Unpacking libqt5printsupport5t64:arm64 (5.15.15+dfsg-4ubuntu1) ... 187s Selecting previously unselected package libqt5test5t64:arm64. 187s Preparing to unpack .../092-libqt5test5t64_5.15.15+dfsg-4ubuntu1_arm64.deb ... 187s Unpacking libqt5test5t64:arm64 (5.15.15+dfsg-4ubuntu1) ... 188s Selecting previously unselected package libraqm0:arm64. 188s Preparing to unpack .../093-libraqm0_0.10.2-1_arm64.deb ... 188s Unpacking libraqm0:arm64 (0.10.2-1) ... 188s Selecting previously unselected package libsharpyuv0:arm64. 188s Preparing to unpack .../094-libsharpyuv0_1.5.0-0.1_arm64.deb ... 188s Unpacking libsharpyuv0:arm64 (1.5.0-0.1) ... 188s Selecting previously unselected package libjbig0:arm64. 188s Preparing to unpack .../095-libjbig0_2.1-6.1ubuntu2_arm64.deb ... 188s Unpacking libjbig0:arm64 (2.1-6.1ubuntu2) ... 188s Selecting previously unselected package libwebp7:arm64. 188s Preparing to unpack .../096-libwebp7_1.5.0-0.1_arm64.deb ... 188s Unpacking libwebp7:arm64 (1.5.0-0.1) ... 188s Selecting previously unselected package libtiff6:arm64. 188s Preparing to unpack .../097-libtiff6_4.7.0-3ubuntu1_arm64.deb ... 188s Unpacking libtiff6:arm64 (4.7.0-3ubuntu1) ... 188s Selecting previously unselected package libwebpdemux2:arm64. 188s Preparing to unpack .../098-libwebpdemux2_1.5.0-0.1_arm64.deb ... 188s Unpacking libwebpdemux2:arm64 (1.5.0-0.1) ... 188s Selecting previously unselected package libwebpmux3:arm64. 188s Preparing to unpack .../099-libwebpmux3_1.5.0-0.1_arm64.deb ... 188s Unpacking libwebpmux3:arm64 (1.5.0-0.1) ... 188s Selecting previously unselected package libxt6t64:arm64. 188s Preparing to unpack .../100-libxt6t64_1%3a1.2.1-1.2build1_arm64.deb ... 188s Unpacking libxt6t64:arm64 (1:1.2.1-1.2build1) ... 188s Selecting previously unselected package libxmu6:arm64. 188s Preparing to unpack .../101-libxmu6_2%3a1.1.3-3build2_arm64.deb ... 188s Unpacking libxmu6:arm64 (2:1.1.3-3build2) ... 188s Selecting previously unselected package libxpm4:arm64. 188s Preparing to unpack .../102-libxpm4_1%3a3.5.17-1build2_arm64.deb ... 188s Unpacking libxpm4:arm64 (1:3.5.17-1build2) ... 188s Selecting previously unselected package libxaw7:arm64. 188s Preparing to unpack .../103-libxaw7_2%3a1.0.16-1_arm64.deb ... 188s Unpacking libxaw7:arm64 (2:1.0.16-1) ... 188s Selecting previously unselected package libxfont2:arm64. 188s Preparing to unpack .../104-libxfont2_1%3a2.0.6-1build1_arm64.deb ... 188s Unpacking libxfont2:arm64 (1:2.0.6-1build1) ... 188s Selecting previously unselected package libxkbfile1:arm64. 188s Preparing to unpack .../105-libxkbfile1_1%3a1.1.0-1build4_arm64.deb ... 188s Unpacking libxkbfile1:arm64 (1:1.1.0-1build4) ... 188s Selecting previously unselected package libxrandr2:arm64. 188s Preparing to unpack .../106-libxrandr2_2%3a1.5.4-1_arm64.deb ... 188s Unpacking libxrandr2:arm64 (2:1.5.4-1) ... 188s Selecting previously unselected package libxslt1.1:arm64. 188s Preparing to unpack .../107-libxslt1.1_1.1.39-0exp1ubuntu4_arm64.deb ... 188s Unpacking libxslt1.1:arm64 (1.1.39-0exp1ubuntu4) ... 188s Selecting previously unselected package libzopfli1. 188s Preparing to unpack .../108-libzopfli1_1.0.3-3_arm64.deb ... 188s Unpacking libzopfli1 (1.0.3-3) ... 188s Selecting previously unselected package python-matplotlib-data. 188s Preparing to unpack .../109-python-matplotlib-data_3.10.1+dfsg1-3_all.deb ... 188s Unpacking python-matplotlib-data (3.10.1+dfsg1-3) ... 188s Selecting previously unselected package python-tables-data. 188s Preparing to unpack .../110-python-tables-data_3.10.2-2build1_all.deb ... 188s Unpacking python-tables-data (3.10.2-2build1) ... 188s Selecting previously unselected package python3-all. 188s Preparing to unpack .../111-python3-all_3.13.3-1_arm64.deb ... 188s Unpacking python3-all (3.13.3-1) ... 188s Selecting previously unselected package python3-async-generator. 189s Preparing to unpack .../112-python3-async-generator_1.10-4_all.deb ... 189s Unpacking python3-async-generator (1.10-4) ... 189s Selecting previously unselected package python3-bottleneck. 189s Preparing to unpack .../113-python3-bottleneck_1.4.2+ds1-2build1_arm64.deb ... 189s Unpacking python3-bottleneck (1.4.2+ds1-2build1) ... 189s Selecting previously unselected package python3-brotli. 189s Preparing to unpack .../114-python3-brotli_1.1.0-2build4_arm64.deb ... 189s Unpacking python3-brotli (1.1.0-2build4) ... 189s Selecting previously unselected package python3-soupsieve. 189s Preparing to unpack .../115-python3-soupsieve_2.7-1_all.deb ... 189s Unpacking python3-soupsieve (2.7-1) ... 189s Selecting previously unselected package python3-bs4. 189s Preparing to unpack .../116-python3-bs4_4.13.4-1_all.deb ... 189s Unpacking python3-bs4 (4.13.4-1) ... 189s Selecting previously unselected package python3-click. 189s Preparing to unpack .../117-python3-click_8.2.0+0.really.8.1.8-1_all.deb ... 189s Unpacking python3-click (8.2.0+0.really.8.1.8-1) ... 189s Selecting previously unselected package python3-cloudpickle. 189s Preparing to unpack .../118-python3-cloudpickle_3.1.1-1_all.deb ... 189s Unpacking python3-cloudpickle (3.1.1-1) ... 189s Selecting previously unselected package python3-contourpy. 189s Preparing to unpack .../119-python3-contourpy_1.3.1-1build1_arm64.deb ... 189s Unpacking python3-contourpy (1.3.1-1build1) ... 189s Selecting previously unselected package python3-cpuinfo. 189s Preparing to unpack .../120-python3-cpuinfo_9.0.0+git20221119-3_all.deb ... 189s Unpacking python3-cpuinfo (9.0.0+git20221119-3) ... 189s Selecting previously unselected package python3-cycler. 189s Preparing to unpack .../121-python3-cycler_0.12.1-1_all.deb ... 189s Unpacking python3-cycler (0.12.1-1) ... 189s Selecting previously unselected package python3-fsspec. 189s Preparing to unpack .../122-python3-fsspec_2025.3.2-1_all.deb ... 189s Unpacking python3-fsspec (2025.3.2-1) ... 189s Selecting previously unselected package python3-toolz. 189s Preparing to unpack .../123-python3-toolz_1.0.0-2_all.deb ... 189s Unpacking python3-toolz (1.0.0-2) ... 189s Selecting previously unselected package python3-packaging. 189s Preparing to unpack .../124-python3-packaging_25.0-1_all.deb ... 189s Unpacking python3-packaging (25.0-1) ... 189s Selecting previously unselected package python3-locket. 189s Preparing to unpack .../125-python3-locket_1.0.0-2_all.deb ... 189s Unpacking python3-locket (1.0.0-2) ... 189s Selecting previously unselected package python3-partd. 189s Preparing to unpack .../126-python3-partd_1.4.2-1_all.deb ... 189s Unpacking python3-partd (1.4.2-1) ... 189s Selecting previously unselected package python3-dask. 189s Preparing to unpack .../127-python3-dask_2024.12.1+dfsg-2_all.deb ... 189s Unpacking python3-dask (2024.12.1+dfsg-2) ... 189s Selecting previously unselected package python3-decorator. 189s Preparing to unpack .../128-python3-decorator_5.2.1-2_all.deb ... 189s Unpacking python3-decorator (5.2.1-2) ... 189s Selecting previously unselected package python3-defusedxml. 189s Preparing to unpack .../129-python3-defusedxml_0.7.1-3_all.deb ... 189s Unpacking python3-defusedxml (0.7.1-3) ... 190s Selecting previously unselected package python3-et-xmlfile. 190s Preparing to unpack .../130-python3-et-xmlfile_2.0.0-1_all.deb ... 190s Unpacking python3-et-xmlfile (2.0.0-1) ... 190s Selecting previously unselected package python3-execnet. 190s Preparing to unpack .../131-python3-execnet_2.1.1-1_all.deb ... 190s Unpacking python3-execnet (2.1.1-1) ... 190s Selecting previously unselected package python3-platformdirs. 190s Preparing to unpack .../132-python3-platformdirs_4.3.7-1_all.deb ... 190s Unpacking python3-platformdirs (4.3.7-1) ... 190s Selecting previously unselected package python3-fs. 190s Preparing to unpack .../133-python3-fs_2.4.16-7_all.deb ... 190s Unpacking python3-fs (2.4.16-7) ... 190s Selecting previously unselected package python3-lxml:arm64. 190s Preparing to unpack .../134-python3-lxml_5.4.0-1_arm64.deb ... 190s Unpacking python3-lxml:arm64 (5.4.0-1) ... 190s Selecting previously unselected package python3-lz4. 190s Preparing to unpack .../135-python3-lz4_4.4.0+dfsg-2_arm64.deb ... 190s Unpacking python3-lz4 (4.4.0+dfsg-2) ... 190s Selecting previously unselected package python3-scipy. 190s Preparing to unpack .../136-python3-scipy_1.14.1-4ubuntu2_arm64.deb ... 190s Unpacking python3-scipy (1.14.1-4ubuntu2) ... 190s Selecting previously unselected package python3-mpmath. 190s Preparing to unpack .../137-python3-mpmath_1.3.0-1_all.deb ... 190s Unpacking python3-mpmath (1.3.0-1) ... 190s Selecting previously unselected package python3-sympy. 190s Preparing to unpack .../138-python3-sympy_1.13.3-5_all.deb ... 190s Unpacking python3-sympy (1.13.3-5) ... 191s Selecting previously unselected package python3-ufolib2. 191s Preparing to unpack .../139-python3-ufolib2_0.17.1+dfsg1-1_all.deb ... 191s Unpacking python3-ufolib2 (0.17.1+dfsg1-1) ... 191s Selecting previously unselected package python3-zopfli. 191s Preparing to unpack .../140-python3-zopfli_0.2.3.post1-1_arm64.deb ... 191s Unpacking python3-zopfli (0.2.3.post1-1) ... 191s Selecting previously unselected package unicode-data. 191s Preparing to unpack .../141-unicode-data_15.1.0-1_all.deb ... 191s Unpacking unicode-data (15.1.0-1) ... 191s Selecting previously unselected package python3-fonttools. 191s Preparing to unpack .../142-python3-fonttools_4.57.0-1_arm64.deb ... 191s Unpacking python3-fonttools (4.57.0-1) ... 191s Selecting previously unselected package python3-webencodings. 191s Preparing to unpack .../143-python3-webencodings_0.5.1-5_all.deb ... 191s Unpacking python3-webencodings (0.5.1-5) ... 191s Selecting previously unselected package python3-html5lib. 191s Preparing to unpack .../144-python3-html5lib_1.2-2_all.deb ... 191s Unpacking python3-html5lib (1.2-2) ... 191s Selecting previously unselected package python3-sortedcontainers. 191s Preparing to unpack .../145-python3-sortedcontainers_2.4.0-2_all.deb ... 191s Unpacking python3-sortedcontainers (2.4.0-2) ... 191s Selecting previously unselected package python3-hypothesis. 191s Preparing to unpack .../146-python3-hypothesis_6.130.5-1_all.deb ... 191s Unpacking python3-hypothesis (6.130.5-1) ... 191s Selecting previously unselected package python3-iniconfig. 191s Preparing to unpack .../147-python3-iniconfig_1.1.1-2_all.deb ... 191s Unpacking python3-iniconfig (1.1.1-2) ... 191s Selecting previously unselected package python3-kiwisolver. 191s Preparing to unpack .../148-python3-kiwisolver_1.4.7-3build1_arm64.deb ... 191s Unpacking python3-kiwisolver (1.4.7-3build1) ... 191s Selecting previously unselected package libopenjp2-7:arm64. 191s Preparing to unpack .../149-libopenjp2-7_2.5.3-2_arm64.deb ... 191s Unpacking libopenjp2-7:arm64 (2.5.3-2) ... 191s Selecting previously unselected package python3-pil:arm64. 191s Preparing to unpack .../150-python3-pil_11.1.0-5build1_arm64.deb ... 191s Unpacking python3-pil:arm64 (11.1.0-5build1) ... 191s Selecting previously unselected package python3.13-tk. 191s Preparing to unpack .../151-python3.13-tk_3.13.3-2_arm64.deb ... 191s Unpacking python3.13-tk (3.13.3-2) ... 191s Selecting previously unselected package python3-tk:arm64. 191s Preparing to unpack .../152-python3-tk_3.13.3-1_arm64.deb ... 191s Unpacking python3-tk:arm64 (3.13.3-1) ... 191s Selecting previously unselected package python3-pil.imagetk:arm64. 191s Preparing to unpack .../153-python3-pil.imagetk_11.1.0-5build1_arm64.deb ... 191s Unpacking python3-pil.imagetk:arm64 (11.1.0-5build1) ... 191s Selecting previously unselected package python3-matplotlib. 192s Preparing to unpack .../154-python3-matplotlib_3.10.1+dfsg1-3_arm64.deb ... 192s Unpacking python3-matplotlib (3.10.1+dfsg1-3) ... 192s Selecting previously unselected package python3-numexpr. 192s Preparing to unpack .../155-python3-numexpr_2.10.2-1build2_arm64.deb ... 192s Unpacking python3-numexpr (2.10.2-1build2) ... 192s Selecting previously unselected package python3-odf. 192s Preparing to unpack .../156-python3-odf_1.4.2-4_all.deb ... 192s Unpacking python3-odf (1.4.2-4) ... 192s Selecting previously unselected package python3-openpyxl. 192s Preparing to unpack .../157-python3-openpyxl_3.1.5+dfsg-2_all.deb ... 192s Unpacking python3-openpyxl (3.1.5+dfsg-2) ... 192s Selecting previously unselected package python3-pluggy. 192s Preparing to unpack .../158-python3-pluggy_1.5.0-1_all.deb ... 192s Unpacking python3-pluggy (1.5.0-1) ... 192s Selecting previously unselected package python3-py. 192s Preparing to unpack .../159-python3-py_1.11.0-4_all.deb ... 192s Unpacking python3-py (1.11.0-4) ... 192s Selecting previously unselected package python3-pyqt5.sip. 192s Preparing to unpack .../160-python3-pyqt5.sip_12.17.0-1build1_arm64.deb ... 192s Unpacking python3-pyqt5.sip (12.17.0-1build1) ... 192s Selecting previously unselected package python3-pyqt5. 192s Preparing to unpack .../161-python3-pyqt5_5.15.11+dfsg-2_arm64.deb ... 192s Unpacking python3-pyqt5 (5.15.11+dfsg-2) ... 192s Selecting previously unselected package python3-pyreadstat. 192s Preparing to unpack .../162-python3-pyreadstat_1.2.8-1build1_arm64.deb ... 192s Unpacking python3-pyreadstat (1.2.8-1build1) ... 193s Selecting previously unselected package python3-pytest. 193s Preparing to unpack .../163-python3-pytest_8.3.5-2_all.deb ... 193s Unpacking python3-pytest (8.3.5-2) ... 193s Selecting previously unselected package python3-pytest-asyncio. 193s Preparing to unpack .../164-python3-pytest-asyncio_0.25.1-1_all.deb ... 193s Unpacking python3-pytest-asyncio (0.25.1-1) ... 193s Selecting previously unselected package python3-pytest-forked. 193s Preparing to unpack .../165-python3-pytest-forked_1.6.0-3_all.deb ... 193s Unpacking python3-pytest-forked (1.6.0-3) ... 193s Selecting previously unselected package python3-werkzeug. 193s Preparing to unpack .../166-python3-werkzeug_3.1.3-2_all.deb ... 193s Unpacking python3-werkzeug (3.1.3-2) ... 193s Selecting previously unselected package python3-pytest-localserver. 193s Preparing to unpack .../167-python3-pytest-localserver_0.9.0.post0-1_all.deb ... 193s Unpacking python3-pytest-localserver (0.9.0.post0-1) ... 193s Selecting previously unselected package python3-pytest-xdist. 193s Preparing to unpack .../168-python3-pytest-xdist_3.6.1-1_all.deb ... 193s Unpacking python3-pytest-xdist (3.6.1-1) ... 193s Selecting previously unselected package python3-pytestqt. 193s Preparing to unpack .../169-python3-pytestqt_4.4.0-1_all.deb ... 193s Unpacking python3-pytestqt (4.4.0-1) ... 193s Preparing to unpack .../170-python3-pytz_2025.2-2_all.deb ... 193s Unpacking python3-pytz (2025.2-2) over (2025.1-3) ... 194s Selecting previously unselected package python3-greenlet. 194s Preparing to unpack .../171-python3-greenlet_3.1.0-1build1_arm64.deb ... 194s Unpacking python3-greenlet (3.1.0-1build1) ... 194s Selecting previously unselected package python3-sqlalchemy. 194s Preparing to unpack .../172-python3-sqlalchemy_2.0.38+ds1-0ubuntu2_all.deb ... 194s Unpacking python3-sqlalchemy (2.0.38+ds1-0ubuntu2) ... 194s Selecting previously unselected package python3-tables-lib. 194s Preparing to unpack .../173-python3-tables-lib_3.10.2-2build1_arm64.deb ... 194s Unpacking python3-tables-lib (3.10.2-2build1) ... 194s Selecting previously unselected package python3-tables. 194s Preparing to unpack .../174-python3-tables_3.10.2-2build1_all.deb ... 194s Unpacking python3-tables (3.10.2-2build1) ... 194s Selecting previously unselected package python3-tabulate. 194s Preparing to unpack .../175-python3-tabulate_0.9.0-1_all.deb ... 194s Unpacking python3-tabulate (0.9.0-1) ... 194s Selecting previously unselected package python3-tz. 194s Preparing to unpack .../176-python3-tz_2025.2-2_all.deb ... 194s Unpacking python3-tz (2025.2-2) ... 194s Selecting previously unselected package python3-xarray. 194s Preparing to unpack .../177-python3-xarray_2025.03.1-8_all.deb ... 194s Unpacking python3-xarray (2025.03.1-8) ... 194s Selecting previously unselected package python3-xlrd. 194s Preparing to unpack .../178-python3-xlrd_2.0.1-2_all.deb ... 194s Unpacking python3-xlrd (2.0.1-2) ... 194s Selecting previously unselected package python3-xlsxwriter. 194s Preparing to unpack .../179-python3-xlsxwriter_3.1.9-2_all.deb ... 194s Unpacking python3-xlsxwriter (3.1.9-2) ... 194s Selecting previously unselected package python3-zstandard. 194s Preparing to unpack .../180-python3-zstandard_0.23.0-4_arm64.deb ... 194s Unpacking python3-zstandard (0.23.0-4) ... 194s Preparing to unpack .../181-python3.13-gdbm_3.13.3-2_arm64.deb ... 194s Unpacking python3.13-gdbm (3.13.3-2) over (3.13.3-1) ... 194s Selecting previously unselected package tzdata-legacy. 194s Preparing to unpack .../182-tzdata-legacy_2025b-3ubuntu1_all.deb ... 194s Unpacking tzdata-legacy (2025b-3ubuntu1) ... 194s Selecting previously unselected package x11-xkb-utils. 194s Preparing to unpack .../183-x11-xkb-utils_7.7+9_arm64.deb ... 194s Unpacking x11-xkb-utils (7.7+9) ... 194s Selecting previously unselected package xsel. 194s Preparing to unpack .../184-xsel_1.2.1-1_arm64.deb ... 194s Unpacking xsel (1.2.1-1) ... 195s Selecting previously unselected package xserver-common. 195s Preparing to unpack .../185-xserver-common_2%3a21.1.16-1ubuntu1_all.deb ... 195s Unpacking xserver-common (2:21.1.16-1ubuntu1) ... 195s Selecting previously unselected package xvfb. 195s Preparing to unpack .../186-xvfb_2%3a21.1.16-1ubuntu1_arm64.deb ... 195s Unpacking xvfb (2:21.1.16-1ubuntu1) ... 195s Preparing to unpack .../187-zstd_1.5.7+dfsg-1_arm64.deb ... 195s Unpacking zstd (1.5.7+dfsg-1) over (1.5.6+dfsg-2) ... 195s Selecting previously unselected package locales-all. 195s Preparing to unpack .../188-locales-all_2.41-6ubuntu1_arm64.deb ... 195s Unpacking locales-all (2.41-6ubuntu1) ... 196s Setting up libgraphite2-3:arm64 (1.3.14-2ubuntu1) ... 196s Setting up xsel (1.2.1-1) ... 196s Setting up libxcb-dri3-0:arm64 (1.17.0-2) ... 196s Setting up liblcms2-2:arm64 (2.16-2) ... 196s Setting up python3-iniconfig (1.1.1-2) ... 196s Setting up libpixman-1-0:arm64 (0.44.0-3) ... 196s Setting up libsharpyuv0:arm64 (1.5.0-0.1) ... 196s Setting up libwayland-server0:arm64 (1.23.1-3) ... 196s Setting up libx11-xcb1:arm64 (2:1.8.12-1) ... 196s Setting up libdouble-conversion3:arm64 (3.3.1-1) ... 196s Setting up libxcb-xfixes0:arm64 (1.17.0-2) ... 196s Setting up liblerc4:arm64 (4.0.0+ds-5ubuntu1) ... 196s Setting up libxpm4:arm64 (1:3.5.17-1build2) ... 196s Setting up python3-async-generator (1.10-4) ... 196s Setting up libxcb-xinput0:arm64 (1.17.0-2) ... 196s Setting up libxrender1:arm64 (1:0.9.12-1) ... 196s Setting up python3-py (1.11.0-4) ... 197s Setting up python3-lz4 (4.4.0+dfsg-2) ... 197s Setting up libxcb-render0:arm64 (1.17.0-2) ... 197s Setting up python3-defusedxml (0.7.1-3) ... 197s Setting up libglvnd0:arm64 (1.7.0-1build1) ... 197s Setting up fonts-lyx (2.4.3-1) ... 197s Setting up libxcb-glx0:arm64 (1.17.0-2) ... 197s Setting up python3-fsspec (2025.3.2-1) ... 197s Setting up libxcb-keysyms1:arm64 (0.4.1-1) ... 197s Setting up libxcb-shape0:arm64 (1.17.0-2) ... 197s Setting up x11-common (1:7.7+23ubuntu4) ... 197s Setting up libdeflate0:arm64 (1.23-2) ... 197s Setting up python3-tabulate (0.9.0-1) ... 198s Setting up libqhull-r8.0:arm64 (2020.2-6build1) ... 198s Setting up libxcb-render-util0:arm64 (0.3.10-1) ... 198s Setting up libxcb-shm0:arm64 (1.17.0-2) ... 198s Setting up libxcb-icccm4:arm64 (0.4.2-1) ... 198s Setting up python3-sortedcontainers (2.4.0-2) ... 198s Setting up libgomp1:arm64 (15.1.0-2ubuntu1) ... 198s Setting up python3-click (8.2.0+0.really.8.1.8-1) ... 198s Setting up libjbig0:arm64 (2.1-6.1ubuntu2) ... 198s Setting up python3-webencodings (0.5.1-5) ... 198s Setting up python3-pyreadstat (1.2.8-1build1) ... 198s Setting up locales-all (2.41-6ubuntu1) ... 198s Setting up libpcre2-16-0:arm64 (10.45-1) ... 198s Setting up libaec0:arm64 (1.1.3-1) ... 198s Setting up python3-platformdirs (4.3.7-1) ... 198s Setting up libxcb-util1:arm64 (0.4.1-1) ... 198s Setting up libxxf86vm1:arm64 (1:1.1.4-1build4) ... 198s Setting up python3-cloudpickle (3.1.1-1) ... 198s Setting up libsnappy1v5:arm64 (1.2.2-1) ... 198s Setting up libxcb-xkb1:arm64 (1.17.0-2) ... 198s Setting up libxcb-image0:arm64 (0.4.0-2build1) ... 198s Setting up python3-fs (2.4.16-7) ... 199s Setting up tzdata (2025b-3ubuntu1) ... 199s 199s Current default time zone: 'Etc/UTC' 199s Local time is now: Tue May 6 17:26:59 UTC 2025. 199s Universal Time is now: Tue May 6 17:26:59 UTC 2025. 199s Run 'dpkg-reconfigure tzdata' if you wish to change it. 199s 199s Setting up libxcb-present0:arm64 (1.17.0-2) ... 199s Setting up unicode-data (15.1.0-1) ... 199s Setting up libpython3.13-minimal:arm64 (3.13.3-2) ... 199s Setting up libqt5core5t64:arm64 (5.15.15+dfsg-4ubuntu1) ... 199s Setting up python3-decorator (5.2.1-2) ... 199s Setting up libblosc2-4:arm64 (2.17.1+ds-1) ... 199s Setting up libfontenc1:arm64 (1:1.1.8-1build1) ... 199s Setting up python3-zstandard (0.23.0-4) ... 199s Setting up python3-packaging (25.0-1) ... 199s Setting up libxcb-xinerama0:arm64 (1.17.0-2) ... 199s Setting up python3-xlsxwriter (3.1.9-2) ... 199s Setting up libzopfli1 (1.0.3-3) ... 199s Setting up libxcb-sync1:arm64 (1.17.0-2) ... 199s Setting up python3-werkzeug (3.1.3-2) ... 200s Setting up python3-brotli (1.1.0-2build4) ... 200s Setting up libavahi-common-data:arm64 (0.8-16ubuntu2) ... 200s Setting up python3-greenlet (3.1.0-1build1) ... 200s Setting up python3-cycler (0.12.1-1) ... 200s Setting up libimagequant0:arm64 (2.18.0-1build1) ... 200s Setting up libxkbcommon-x11-0:arm64 (1.7.0-2) ... 200s Setting up fonts-dejavu-mono (2.37-8) ... 200s Setting up python3-kiwisolver (1.4.7-3build1) ... 200s Setting up python3-bottleneck (1.4.2+ds1-2build1) ... 200s Setting up libxrandr2:arm64 (2:1.5.4-1) ... 200s Setting up libtcl8.6:arm64 (8.6.16+dfsg-1) ... 200s Setting up fonts-dejavu-core (2.37-8) ... 200s Setting up python3-numexpr (2.10.2-1build2) ... 201s Setting up libjpeg-turbo8:arm64 (2.1.5-3ubuntu2) ... 201s Setting up python3-cpuinfo (9.0.0+git20221119-3) ... 201s Setting up python3-html5lib (1.2-2) ... 201s Setting up libvulkan1:arm64 (1.4.309.0-1) ... 201s Setting up python3-pluggy (1.5.0-1) ... 201s Setting up libwebp7:arm64 (1.5.0-0.1) ... 201s Setting up python3-pyqt5.sip (12.17.0-1build1) ... 201s Setting up libmtdev1t64:arm64 (1.1.7-1) ... 201s Setting up libxshmfence1:arm64 (1.3.3-1) ... 201s Setting up libxcb-randr0:arm64 (1.17.0-2) ... 201s Setting up libxslt1.1:arm64 (1.1.39-0exp1ubuntu4) ... 201s Setting up libblosc1:arm64 (1.21.5+ds-1build1) ... 201s Setting up python3-et-xmlfile (2.0.0-1) ... 201s Setting up libqt5sql5t64:arm64 (5.15.15+dfsg-4ubuntu1) ... 201s Setting up libmd4c0:arm64 (0.5.2-2) ... 201s Setting up python3-xlrd (2.0.1-2) ... 201s Setting up libopenjp2-7:arm64 (2.5.3-2) ... 201s Setting up python3.13-minimal (3.13.3-2) ... 202s Setting up python3-toolz (1.0.0-2) ... 203s Setting up libharfbuzz0b:arm64 (10.2.0-1) ... 203s Setting up python3-contourpy (1.3.1-1build1) ... 203s Setting up libxss1:arm64 (1:1.2.3-1build3) ... 203s Setting up libxkbfile1:arm64 (1:1.1.0-1build4) ... 203s Setting up libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 203s Setting up python3-mpmath (1.3.0-1) ... 203s Setting up python3-execnet (2.1.1-1) ... 203s Setting up python-matplotlib-data (3.10.1+dfsg1-3) ... 203s Setting up libwebpmux3:arm64 (1.5.0-0.1) ... 203s Setting up python3-locket (1.0.0-2) ... 204s Setting up libxfont2:arm64 (1:2.0.6-1build1) ... 204s Setting up libpython3.13-stdlib:arm64 (3.13.3-2) ... 204s Setting up python3-soupsieve (2.7-1) ... 204s Setting up python-tables-data (3.10.2-2build1) ... 204s Setting up zstd (1.5.7+dfsg-1) ... 204s Setting up libsz2:arm64 (1.1.3-1) ... 204s Setting up python3.13-gdbm (3.13.3-2) ... 204s Setting up liblbfgsb0:arm64 (3.0+dfsg.4-1build1) ... 204s Setting up python3-odf (1.4.2-4) ... 204s Setting up libwacom-common (2.14.0-1) ... 204s Setting up libwayland-client0:arm64 (1.23.1-3) ... 204s Setting up libpython3.13:arm64 (3.13.3-2) ... 204s Setting up libjpeg8:arm64 (8c-2ubuntu11) ... 204s Setting up python3-partd (1.4.2-1) ... 204s Setting up python3-sympy (1.13.3-5) ... 210s Setting up libice6:arm64 (2:1.1.1-1) ... 210s Setting up mesa-libgallium:arm64 (25.0.3-1ubuntu2) ... 210s Setting up libqt5dbus5t64:arm64 (5.15.15+dfsg-4ubuntu1) ... 210s Setting up python3-scipy (1.14.1-4ubuntu2) ... 214s Setting up libgbm1:arm64 (25.0.3-1ubuntu2) ... 214s Setting up python3.13 (3.13.3-2) ... 215s Setting up libwacom9:arm64 (2.14.0-1) ... 215s Setting up fontconfig-config (2.15.0-2.2ubuntu1) ... 215s Setting up python3-pytest (8.3.5-2) ... 215s Setting up python3-pytest-localserver (0.9.0.post0-1) ... 216s Setting up libwebpdemux2:arm64 (1.5.0-0.1) ... 216s Setting up python3-hypothesis (6.130.5-1) ... 216s Setting up python3-xarray (2025.03.1-8) ... 217s Setting up libgl1-mesa-dri:arm64 (25.0.3-1ubuntu2) ... 217s Setting up libqt5network5t64:arm64 (5.15.15+dfsg-4ubuntu1) ... 217s Setting up libavahi-common3:arm64 (0.8-16ubuntu2) ... 217s Setting up python3-dask (2024.12.1+dfsg-2) ... 219s Setting up libqt5xml5t64:arm64 (5.15.15+dfsg-4ubuntu1) ... 219s Setting up python3-all (3.13.3-1) ... 219s Setting up python3-pytz (2025.2-2) ... 219s Setting up libqt5test5t64:arm64 (5.15.15+dfsg-4ubuntu1) ... 219s Setting up tzdata-legacy (2025b-3ubuntu1) ... 219s Setting up python3-tz (2025.2-2) ... 219s Setting up python3-bs4 (4.13.4-1) ... 219s Setting up python3-zopfli (0.2.3.post1-1) ... 219s Setting up python3-sqlalchemy (2.0.38+ds1-0ubuntu2) ... 221s Setting up libinput-bin (1.28.1-1) ... 221s Setting up python3-pytest-forked (1.6.0-3) ... 221s Setting up libegl-mesa0:arm64 (25.0.3-1ubuntu2) ... 221s Setting up libjs-jquery-ui (1.13.2+dfsg-1) ... 221s Setting up libraqm0:arm64 (0.10.2-1) ... 221s Setting up python3-pytest-asyncio (0.25.1-1) ... 221s Setting up libhdf5-310:arm64 (1.14.5+repack-3) ... 221s Setting up python3-lxml:arm64 (5.4.0-1) ... 221s Setting up libtiff6:arm64 (4.7.0-3ubuntu1) ... 221s Setting up libegl1:arm64 (1.7.0-1build1) ... 221s Setting up libfontconfig1:arm64 (2.15.0-2.2ubuntu1) ... 221s Setting up libsm6:arm64 (2:1.2.6-1) ... 221s Setting up python3-pytestqt (4.4.0-1) ... 221s Setting up libavahi-client3:arm64 (0.8-16ubuntu2) ... 221s Setting up libinput10:arm64 (1.28.1-1) ... 221s Setting up fontconfig (2.15.0-2.2ubuntu1) ... 223s Regenerating fonts cache... done. 223s Setting up libxft2:arm64 (2.3.6-1build1) ... 223s Setting up libglx-mesa0:arm64 (25.0.3-1ubuntu2) ... 223s Setting up python3-pytest-xdist (3.6.1-1) ... 223s Setting up libglx0:arm64 (1.7.0-1build1) ... 223s Setting up python3-tables-lib (3.10.2-2build1) ... 223s Setting up libtk8.6:arm64 (8.6.16-1) ... 223s Setting up python3-tables (3.10.2-2build1) ... 224s Setting up python3.13-tk (3.13.3-2) ... 224s Setting up python3-pil:arm64 (11.1.0-5build1) ... 224s Setting up libgl1:arm64 (1.7.0-1build1) ... 224s Setting up python3-openpyxl (3.1.5+dfsg-2) ... 225s Setting up libxt6t64:arm64 (1:1.2.1-1.2build1) ... 225s Setting up libcups2t64:arm64 (2.4.12-0ubuntu1) ... 225s Setting up tk8.6-blt2.5 (2.5.3+dfsg-8) ... 225s Setting up libxmu6:arm64 (2:1.1.3-3build2) ... 225s Setting up blt (2.5.3+dfsg-8) ... 225s Setting up python3-tk:arm64 (3.13.3-1) ... 225s Setting up libxaw7:arm64 (2:1.0.16-1) ... 225s Setting up libqt5gui5t64:arm64 (5.15.15+dfsg-4ubuntu1) ... 225s Setting up python3-pil.imagetk:arm64 (11.1.0-5build1) ... 225s Setting up libqt5widgets5t64:arm64 (5.15.15+dfsg-4ubuntu1) ... 225s Setting up x11-xkb-utils (7.7+9) ... 225s Setting up libqt5help5:arm64 (5.15.15-6build1) ... 225s Setting up xserver-common (2:21.1.16-1ubuntu1) ... 225s Setting up libqt5printsupport5t64:arm64 (5.15.15+dfsg-4ubuntu1) ... 225s Setting up libqt5designer5:arm64 (5.15.15-6build1) ... 225s Setting up xvfb (2:21.1.16-1ubuntu1) ... 225s Setting up python3-pyqt5 (5.15.11+dfsg-2) ... 225s Setting up python3-ufolib2 (0.17.1+dfsg1-1) ... 225s Setting up python3-fonttools (4.57.0-1) ... 226s Setting up python3-matplotlib (3.10.1+dfsg1-3) ... 228s Processing triggers for libc-bin (2.41-6ubuntu1) ... 228s Processing triggers for systemd (257.4-1ubuntu3) ... 228s Processing triggers for man-db (2.13.1-1) ... 228s Processing triggers for udev (257.4-1ubuntu3) ... 229s autopkgtest [17:27:29]: test unittests3: [----------------------- 230s ++ dpkg --print-architecture 230s + arch=arm64 230s ++ py3versions -s 230s + pys=python3.13 230s + sourcetestroot=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests 230s + tomlfile=/tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 230s + echo amd64 i386 230s + grep arm64 230s + marker='not slow' 230s + echo arm64 230s + grep -E 'mips|hppa' 230s + PYTEST_WARN_IGNORE= 230s + cd /tmp/autopkgtest.k7pV9B/autopkgtest_tmp 230s === python3.13 === 230s + TEST_SUCCESS=true 230s + for py in $pys 230s + echo '=== python3.13 ===' 230s ++ python3.13 -c 'import pandas as pd; print(pd.__path__[0])' 230s + modpath=/usr/lib/python3/dist-packages/pandas 230s + for TEST_SUBSET in $modpath/tests/* 230s + echo /usr/lib/python3/dist-packages/pandas/tests/__init__.py 230s + grep -q -e __pycache__ 230s + PANDAS_CI=1 230s + LC_ALL=C.UTF-8 230s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/__init__.py 232s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 232s 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" 232s 232s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 232s ============================= test session starts ============================== 232s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 232s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 232s rootdir: /usr/lib/python3/dist-packages/pandas 232s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 232s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 232s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 232s collected 0 items 232s 232s =============================== warnings summary =============================== 232s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 232s /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-y6k173sx' 232s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 232s 232s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 232s /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-hl0o4933' 232s session.config.cache.set(STEPWISE_CACHE_DIR, []) 232s 232s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 232s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 232s ============================= 2 warnings in 0.12s ============================== 232s rdjoqkol test state = true 232s + test 5 == 5 232s + echo 'rdjoqkol test state = true' 232s + for TEST_SUBSET in $modpath/tests/* 232s + echo /usr/lib/python3/dist-packages/pandas/tests/__pycache__ 232s + grep -q -e __pycache__ 232s rdjoqkol test state = true 232s + echo 'rdjoqkol test state = true' 232s + for TEST_SUBSET in $modpath/tests/* 232s + echo /usr/lib/python3/dist-packages/pandas/tests/api 232s + grep -q -e __pycache__ 232s + PANDAS_CI=1 232s + LC_ALL=C.UTF-8 232s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/api 233s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 233s 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" 233s 233s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 233s ============================= test session starts ============================== 233s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 233s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 233s rootdir: /usr/lib/python3/dist-packages/pandas 233s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 233s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 233s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 233s collected 14 items 233s 233s ../../../usr/lib/python3/dist-packages/pandas/tests/api/test_api.py ............ 233s ../../../usr/lib/python3/dist-packages/pandas/tests/api/test_types.py .. 233s 233s =============================== warnings summary =============================== 233s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 233s /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-v8p5qy1f' 233s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 233s 233s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 233s /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-p2z0sc5o' 233s session.config.cache.set(STEPWISE_CACHE_DIR, []) 233s 233s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 233s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 233s ============================= slowest 30 durations ============================= 233s 233s (30 durations < 0.005s hidden. Use -vv to show these durations.) 233s ======================== 14 passed, 2 warnings in 0.12s ======================== 233s rdjoqkol test state = true 233s + echo 'rdjoqkol test state = true' 233s + for TEST_SUBSET in $modpath/tests/* 233s + echo /usr/lib/python3/dist-packages/pandas/tests/apply 233s + grep -q -e __pycache__ 233s + PANDAS_CI=1 233s + LC_ALL=C.UTF-8 233s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/apply 234s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 234s 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" 234s 234s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 235s ============================= test session starts ============================== 235s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 235s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 235s rootdir: /usr/lib/python3/dist-packages/pandas 235s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 235s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 235s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 235s collected 1243 items 235s 235s ../../../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....... 236s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_frame_apply_relabeling.py ..x.. 237s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_frame_transform.py ...s.s.s................................................ss..ss..ss.....x........x........x........ 237s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_invalid_arg.py ....................................................................................................................................................................................................... 237s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_numba.py sssssssssssssssssss 238s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_series_apply.py ................................x.....x....x........................................................................................ 238s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_series_apply_relabeling.py .. 238s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_series_transform.py ............ 242s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_str.py ....................xxxxx...................................................................................................................................................................................................................................................................................................................................................................................................................................................................x...........x...........x...........x...........x........ 242s 242s =============================== warnings summary =============================== 242s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 242s /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-78vuut8p' 242s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 242s 242s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 242s /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-b4pggfz2' 242s session.config.cache.set(STEPWISE_CACHE_DIR, []) 242s 242s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 242s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 242s ============================= slowest 30 durations ============================= 242s 0.06s call tests/apply/test_frame_apply.py::test_apply_differently_indexed 242s 0.04s call tests/apply/test_frame_apply.py::test_agg_transform[axis=1] 242s 0.04s call tests/apply/test_frame_apply.py::test_agg_transform[axis='columns'] 242s 0.03s call tests/apply/test_frame_apply.py::test_agg_reduce[axis='columns'] 242s 0.02s call tests/apply/test_frame_apply.py::test_agg_reduce[axis=1] 242s 0.02s call tests/apply/test_frame_transform.py::test_transform_listlike[axis=1-ops3-names3] 242s 0.02s call tests/apply/test_frame_transform.py::test_transform_listlike[axis=1-ops1-names1] 242s 0.02s call tests/apply/test_frame_transform.py::test_transform_listlike[axis='columns'-ops1-names1] 242s 0.02s call tests/apply/test_frame_transform.py::test_transform_listlike[axis='columns'-ops3-names3] 242s 0.02s call tests/apply/test_series_apply.py::test_transform[False] 242s 0.02s call tests/apply/test_frame_transform.py::test_transform_listlike[axis='columns'-ops0-names0] 242s 0.02s call tests/apply/test_frame_transform.py::test_transform_listlike[axis=1-ops2-names2] 242s 0.02s call tests/apply/test_frame_transform.py::test_transform_listlike[axis=1-ops0-names0] 242s 0.01s call tests/apply/test_frame_transform.py::test_transform_listlike[axis='columns'-ops2-names2] 242s 0.01s call tests/apply/test_series_apply.py::test_transform[compat] 242s 0.01s call tests/apply/test_str.py::test_transform_groupby_kernel_frame[axis='columns'-pct_change] 242s 0.01s call tests/apply/test_str.py::test_transform_groupby_kernel_frame[axis=1-pct_change] 242s 0.01s call tests/apply/test_frame_apply.py::test_agg_reduce[axis=0] 242s 0.01s call tests/apply/test_frame_apply.py::test_agg_reduce[axis='index'] 242s 0.01s call tests/apply/test_frame_apply_relabeling.py::test_agg_namedtuple 242s 0.01s call tests/apply/test_frame_apply.py::test_agg_transform[axis=0] 242s 0.01s call tests/apply/test_frame_apply.py::test_agg_transform[axis='index'] 242s 0.01s call tests/apply/test_frame_apply_relabeling.py::test_agg_relabel_partial_functions 242s 0.01s call tests/apply/test_frame_apply_relabeling.py::test_agg_relabel 242s 0.01s call tests/apply/test_series_apply.py::test_with_nested_series[agg] 242s 0.01s call tests/apply/test_frame_apply_relabeling.py::test_agg_relabel_multi_columns_multi_methods 242s 0.01s call tests/apply/test_str.py::test_transform_groupby_kernel_frame[axis='index'-pct_change] 242s 0.01s call tests/apply/test_str.py::test_transform_groupby_kernel_frame[axis=0-pct_change] 242s 0.01s call tests/apply/test_frame_apply.py::test_nuiscance_columns 242s 0.01s call tests/apply/test_series_apply.py::test_with_nested_series[apply] 242s =========== 1153 passed, 73 skipped, 17 xfailed, 2 warnings in 7.69s =========== 242s + echo 'rdjoqkol test state = true' 242s + for TEST_SUBSET in $modpath/tests/* 242s + echo /usr/lib/python3/dist-packages/pandas/tests/arithmetic 242s + grep -q -e __pycache__ 242s + PANDAS_CI=1 242s + LC_ALL=C.UTF-8 242s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/arithmetic 242s rdjoqkol test state = true 243s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 243s 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" 243s 243s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 245s ============================= test session starts ============================== 245s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 245s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 245s rootdir: /usr/lib/python3/dist-packages/pandas 245s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 245s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 245s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 245s collected 19330 items 245s 245s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_array_ops.py .. 245s ../../../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 ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 308s ../../../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............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 308s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_object.py .......s........................................................................................... 309s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_period.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 314s ../../../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......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 314s 314s =============================== warnings summary =============================== 314s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 314s /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-ek9ookjl' 314s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 314s 314s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 314s /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-u66h1l9c' 314s session.config.cache.set(STEPWISE_CACHE_DIR, []) 314s 314s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 314s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 314s ============================= slowest 30 durations ============================= 314s 0.30s call tests/arithmetic/test_datetime64.py::TestDatetimeIndexArithmetic::test_dti_addsub_object_arraylike[None-Series-Index] 314s 0.18s call tests/arithmetic/test_datetime64.py::TestDatetime64Arithmetic::test_dt64arr_sub_timedeltalike_scalar[pytz.FixedOffset(300)-timedelta64_0-DataFrame] 314s 0.09s teardown tests/arithmetic/test_timedelta64.py::test_add_timestamp_to_timedelta 314s 0.05s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_relativedelta_offsets[DataFrame-ms] 314s 0.05s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_relativedelta_offsets[DataFrame-s] 314s 0.05s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_relativedelta_offsets[DataFrame-us] 314s 0.05s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_relativedelta_offsets[DataFrame-ns] 314s 0.04s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-5-True-cls_and_kwargs27] 314s 0.04s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-us-5-True-cls_and_kwargs27] 314s 0.04s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-5-True-cls_and_kwargs27] 314s 0.04s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-5-False-cls_and_kwargs27] 314s 0.04s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-us-5-False-cls_and_kwargs27] 314s 0.04s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-5-False-cls_and_kwargs27] 314s 0.04s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ns-5-True-cls_and_kwargs27] 314s 0.04s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ns-5-False-cls_and_kwargs27] 314s 0.04s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-0-True-CBMonthBegin] 314s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-ns-5-True-cls_and_kwargs27] 314s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-ms-5-True-cls_and_kwargs27] 314s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-us-5-True-cls_and_kwargs27] 314s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-ms-5-False-cls_and_kwargs27] 314s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-ns-5-False-cls_and_kwargs27] 314s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-s-5-False-cls_and_kwargs27] 314s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-0-False-CBMonthBegin] 314s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-us-5-False-cls_and_kwargs27] 314s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-s-5-True-cls_and_kwargs27] 314s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-0-True-CBMonthBegin] 314s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-us-5-True-CBMonthBegin] 314s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-5-True-CBMonthBegin] 314s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-0-True-CBMonthEnd] 314s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-us-0-True-CBMonthBegin] 314s ========== 19158 passed, 172 skipped, 2 warnings in 70.39s (0:01:10) =========== 315s rdjoqkol test state = true 315s + echo 'rdjoqkol test state = true' 315s + for TEST_SUBSET in $modpath/tests/* 315s + echo /usr/lib/python3/dist-packages/pandas/tests/arrays 315s + grep -q -e __pycache__ 315s + PANDAS_CI=1 315s + LC_ALL=C.UTF-8 315s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/arrays 316s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 316s 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" 316s 316s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 320s ============================= test session starts ============================== 320s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 320s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 320s rootdir: /usr/lib/python3/dist-packages/pandas 320s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 320s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 320s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 320s collected 19230 items / 2 skipped 320s 320s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_arithmetic.py ..................... 320s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_astype.py ... 320s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_comparison.py .................................... 320s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_construction.py ............................. 320s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_function.py ........... 320s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_indexing.py ... 320s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_logical.py ................................................................................... 320s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_ops.py .. 320s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_reduction.py .............................. 320s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_repr.py . 320s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_algos.py .............. 320s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_analytics.py ........x..x................................................ 320s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_api.py ................................................................. 320s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_astype.py ...................... 321s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_constructors.py ....................................................................................................................... 321s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_dtypes.py .................................. 321s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_indexing.py ............................................................................................................................................... 321s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_map.py ............................. 321s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_missing.py .......................... 321s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_operators.py ...................................... 321s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_replace.py ...................... 321s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_repr.py ....................... 321s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_sorting.py .... 321s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_subclass.py ... 321s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_take.py ................ 321s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_warnings.py s 321s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/datetimes/test_constructors.py ......................ssssssssssssss 321s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/datetimes/test_cumulative.py ... 322s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/datetimes/test_reductions.py ................................................................................................................................................................................................................. 322s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_arithmetic.py .............................................................. 322s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_astype.py ......... 322s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_comparison.py .................................................................................................................. 322s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_concat.py ... 322s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_construction.py ............................... 322s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_contains.py . 322s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_function.py .................................................... 322s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_repr.py ........ 322s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_to_numpy.py .............................. 323s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_arithmetic.py ................................................................................................................................................................................................................................................................................................................................................... 324s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_comparison.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 324s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_concat.py .................. 324s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_construction.py ............................................... 324s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_dtypes.py ......................................................................................................................... 324s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_function.py ............................................................................................................................. 325s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_indexing.py .. 325s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_reduction.py ............................................... 325s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_repr.py .......................... 325s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_astype.py .. 325s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_formats.py . 325s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_interval.py .............................................................................. 325s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_interval_pyarrow.py ssssssss 325s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_overlaps.py .................................................................................................................... 327s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/masked/test_arithmetic.py ..............................................................................................................................................ss........................................................................................................................................................ss........................................................................................................................................................ss........................................................................................................................................................ss........................................................................................................................................................ss............................................................................................................................................................................................................................................................................................................................................................... 327s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/masked/test_function.py ..................... 327s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/masked/test_indexing.py ........................................................................................................... 327s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/numpy_/test_indexing.py ....................................... 327s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/numpy_/test_numpy.py ....................................................................................... 327s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/period/test_astype.py .......... 327s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/period/test_constructors.py ..................... 327s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/period/test_reductions.py ... 328s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_accessor.py ............................................. 330s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_arithmetics.py ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 330s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_array.py ........................................................................... 330s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_astype.py ........................ 330s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_combine_concat.py .......... 330s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_constructors.py ................................. 330s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_dtype.py ........................................................ 331s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_indexing.py ................................................................................ 331s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_libsparse.py ..................................................................................... 331s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_reductions.py ....................................................................... 331s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_unary.py ......... 332s ../../../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 332s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/string_/test_string_arrow.py s.ss.ssssssssss.ssssssssssssssssssssssssssssssssss 332s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_array.py ....................................................................................... 352s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_datetimelike.py ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ssssss....................................................................................................................................................................................................ssssssssssssssssssssssssssssssssssss.......................................................................................................................................................................................................................................................................................................................................... 357s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_datetimes.py ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 357s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_ndarray_backed.py ..... 357s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_period.py ................... 357s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_timedeltas.py ...................................................................................................................................................... 357s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/timedeltas/test_constructors.py ........ 357s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/timedeltas/test_cumulative.py ..... 358s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/timedeltas/test_reductions.py .......................... 358s 358s =============================== warnings summary =============================== 358s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 358s /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-tyq1bb4q' 358s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 358s 358s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 358s /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-ca0j2092' 358s session.config.cache.set(STEPWISE_CACHE_DIR, []) 358s 358s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 358s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 358s ============================= slowest 30 durations ============================= 358s 0.38s call tests/arrays/test_timedeltas.py::TestNonNano::test_mul_listlike_object[s] 358s 0.27s call tests/arrays/test_datetimelike.py::TestDatetimeArray::test_setitem_object_dtype['UTC+01:15'-QE-Index] 358s 0.22s setup tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_bool_array_logical[integer-True] 358s 0.13s call tests/arrays/sparse/test_accessor.py::TestSeriesAccessor::test_from_coo 358s 0.12s teardown tests/arrays/timedeltas/test_reductions.py::TestReductions::test_mean_2d 358s 0.04s call tests/arrays/categorical/test_dtypes.py::TestCategoricalDtypes::test_codes_dtypes 358s 0.02s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_mixed_array_comparison[block] 358s 0.02s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_mixed_array_comparison[integer] 358s 0.02s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_scalar_comparison[block] 358s 0.02s call tests/arrays/integer/test_arithmetic.py::test_values_multiplying_large_series_by_NA 358s 0.02s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_int_array_comparison[integer] 358s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_int_array_comparison[block] 358s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_array_comparison[block] 358s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_array_comparison[integer] 358s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_scalar_comparison[integer] 358s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_int_array[integer-True-rmul] 358s 0.01s call tests/arrays/integer/test_arithmetic.py::test_reduce_to_float[mean] 358s 0.01s setup tests/arrays/test_datetimelike.py::TestDatetimeArray::test_setitem_raises[datetime.timezone.utc-ME] 358s 0.01s setup tests/arrays/test_datetimes.py::TestNonNano::test_fields[ms-zoneinfo.ZoneInfo(key='US/Pacific')-dayofweek] 358s 0.01s call tests/arrays/test_datetimelike.py::TestDatetimeArray::test_round['-02:15'-QE] 358s 0.01s setup tests/arrays/test_datetimelike.py::TestDatetimeArray::test_bool_properties[zoneinfo.ZoneInfo(key='US/Pacific')-YE-is_year_start] 358s 0.01s call tests/arrays/test_datetimelike.py::TestTimedeltaArray::test_setitem_numeric_raises[array] 358s 0.01s setup tests/arrays/masked/test_arithmetic.py::test_numpy_array_equivalence[Float32-__rtruediv__] 358s 0.01s setup tests/arrays/test_datetimelike.py::TestDatetimeArray::test_int_properties[datetime.timezone(datetime.timedelta(seconds=3600))-B-quarter] 358s 0.01s call tests/arrays/test_datetimes.py::TestNonNano::test_time_date[s-datetime.timezone(datetime.timedelta(seconds=3600))-time] 358s 0.01s setup tests/arrays/integer/test_function.py::test_integer_array_prod[Int64-9-False] 358s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[float64-labels1-coo] 358s 0.01s call tests/arrays/sparse/test_accessor.py::TestFrameAccessor::test_from_spmatrix[float64-None-csc] 358s 0.01s call tests/arrays/datetimes/test_reductions.py::TestReductions::test_min_max[ns-None] 358s 0.01s setup tests/arrays/test_datetimelike.py::TestDatetimeArray::test_take_fill_raises['UTC+01:15'-B-2] 358s ========= 18203 passed, 1021 skipped, 8 xfailed, 2 warnings in 41.35s ========== 359s + echo 'rdjoqkol test state = true' 359s + for TEST_SUBSET in $modpath/tests/* 359s + echo /usr/lib/python3/dist-packages/pandas/tests/base 359s + grep -q -e __pycache__ 359s rdjoqkol test state = true 359s + PANDAS_CI=1 359s + LC_ALL=C.UTF-8 359s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/base 360s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 360s 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" 360s 360s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 361s ============================= test session starts ============================== 361s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 361s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 361s rootdir: /usr/lib/python3/dist-packages/pandas 361s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 361s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 361s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 361s collected 1775 items 361s 361s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_constructors.py ....................... 361s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_conversion.py ................................................................................................................................................................................................................................................................................................................................... 361s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_fillna.py ..................................................................................ssssssssssssssssss....ssss........ssssssssss......ss..............................................ss......................ssssssssssss 362s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_misc.py .......................................................................................................................................................................................................................................xx...xxx....................................................................s...... 362s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_transpose.py .............................................................................................................................................................................................................................. 363s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_unique.py ..................................................................................ssssssssssssssssss....ssss........ssssssssss......ss..............................................ss......................ssssssssssss..................................................................................ssssssssssssssssss....ssss..........ssssssss......ss......................................................................ssssssssssss.... 364s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_value_counts.py ..................................................................................ssssssssssssssssss....ssss........ssssssssss......ss..............................................ss......................ssssssssssss......................... 364s 364s =============================== warnings summary =============================== 364s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 364s /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-vf608ote' 364s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 364s 364s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 364s /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-_4pkh1p5' 364s session.config.cache.set(STEPWISE_CACHE_DIR, []) 364s 364s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 364s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 364s ============================= slowest 30 durations ============================= 364s 0.08s setup tests/base/test_misc.py::test_memory_usage[series-with-string-python-index] 364s 0.04s call tests/base/test_value_counts.py::test_value_counts_null[interval-None] 364s 0.04s call tests/base/test_value_counts.py::test_value_counts_null[interval-nan] 364s 0.02s call tests/base/test_value_counts.py::test_value_counts[interval] 364s 0.02s call tests/base/test_value_counts.py::test_value_counts_null[datetime-tz-None] 364s 0.02s call tests/base/test_value_counts.py::test_value_counts_null[datetime-tz-nan] 364s 0.01s call tests/base/test_value_counts.py::test_value_counts[datetime-tz] 364s 0.01s call tests/base/test_value_counts.py::test_value_counts_bins[index] 364s 0.01s call tests/base/test_unique.py::test_unique_null[period-nan] 364s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[period-nan] 364s 0.01s call tests/base/test_unique.py::test_unique_null[datetime-tz-nan] 364s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[period-None] 364s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[timedelta-nan] 364s 0.01s call tests/base/test_unique.py::test_unique[datetime-tz] 364s 0.01s call tests/base/test_unique.py::test_unique_null[datetime-tz-None] 364s 0.01s call tests/base/test_value_counts.py::test_value_counts_bins[series] 364s 0.01s call tests/base/test_unique.py::test_unique_null[timedelta-nan] 364s 0.01s call tests/base/test_unique.py::test_unique_null[timedelta-None] 364s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[timedelta-None] 364s 0.01s call tests/base/test_unique.py::test_unique[timedelta] 364s 0.01s call tests/base/test_unique.py::test_unique_null[datetime-None] 364s 0.01s call tests/base/test_unique.py::test_unique_null[datetime-nan] 364s 0.01s call tests/base/test_value_counts.py::test_value_counts[period] 364s 0.01s call tests/base/test_unique.py::test_unique[datetime] 364s 0.01s call tests/base/test_value_counts.py::test_value_counts[timedelta] 364s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[datetime-nan] 364s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[datetime-None] 364s 0.01s call tests/base/test_value_counts.py::test_value_counts[datetime] 364s 0.01s call tests/base/test_unique.py::test_unique_null[period-None] 364s 0.01s call tests/base/test_unique.py::test_unique[period] 364s =========== 1581 passed, 189 skipped, 5 xfailed, 2 warnings in 4.13s =========== 365s rdjoqkol test state = true 365s + echo 'rdjoqkol test state = true' 365s + for TEST_SUBSET in $modpath/tests/* 365s + echo /usr/lib/python3/dist-packages/pandas/tests/computation 365s + grep -q -e __pycache__ 365s + PANDAS_CI=1 365s + LC_ALL=C.UTF-8 365s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/computation 366s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 366s 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" 366s 366s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 367s ============================= test session starts ============================== 367s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 367s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 367s rootdir: /usr/lib/python3/dist-packages/pandas 367s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 367s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 367s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 367s collected 11159 items 367s 367s ../../../usr/lib/python3/dist-packages/pandas/tests/computation/test_compat.py ..... 423s ../../../usr/lib/python3/dist-packages/pandas/tests/computation/test_eval.py ..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................xx..............................xx..............................xx..............................xx.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................xxxxxxxxxx..................................................xxxxxxxxxx......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................X.........X....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x....................................................................................................................................................................................................................................xx..xx..... 423s 423s =============================== warnings summary =============================== 423s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 423s /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-wfoxay5u' 423s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 423s 423s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 423s /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-lv3j361l' 423s session.config.cache.set(STEPWISE_CACHE_DIR, []) 423s 423s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 423s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 423s ============================= slowest 30 durations ============================= 423s 0.23s call tests/computation/test_eval.py::TestEval::test_floor_division[Series-SeriesNaN-numexpr-python] 423s 0.12s call tests/computation/test_eval.py::TestEval::test_complex_cmp_ops[SeriesNaN-Series-numexpr-pandas-or-lt-le] 423s 0.05s teardown tests/computation/test_eval.py::TestValidate::test_validate_bool_args[5.0] 423s 0.04s call tests/computation/test_eval.py::TestAlignment::test_performance_warning_for_poor_alignment[numexpr-python] 423s 0.04s call tests/computation/test_eval.py::TestAlignment::test_performance_warning_for_poor_alignment[numexpr-pandas] 423s 0.02s call tests/computation/test_eval.py::TestAlignment::test_performance_warning_for_poor_alignment[python-python] 423s 0.02s call tests/computation/test_eval.py::TestAlignment::test_performance_warning_for_poor_alignment[python-pandas] 423s 0.02s call tests/computation/test_eval.py::TestOperations::test_simple_arith_ops[numexpr-python] 423s 0.02s call tests/computation/test_eval.py::TestOperations::test_check_many_exprs[python-python] 423s 0.02s call tests/computation/test_eval.py::TestOperations::test_lhs_expression_subscript 423s 0.02s call tests/computation/test_eval.py::TestOperations::test_nested_period_index_subscript_expression 423s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[numexpr-pandas-&] 423s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[numexpr-python-|] 423s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[numexpr-pandas-|] 423s 0.01s call tests/computation/test_eval.py::TestOperations::test_check_many_exprs[numexpr-python] 423s 0.01s call tests/computation/test_eval.py::TestAlignment::test_series_frame_commutativity[numexpr-python-+-index-i-s] 423s 0.01s call tests/computation/test_eval.py::TestOperations::test_attr_expression 423s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[numexpr-python-&] 423s 0.01s call tests/computation/test_eval.py::TestOperations::test_simple_arith_ops[python-python] 423s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[python-pandas-&] 423s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[python-pandas-|] 423s 0.01s call tests/computation/test_eval.py::TestOperations::test_multi_line_expression 423s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[python-python-|] 423s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[python-python-&] 423s 0.01s call tests/computation/test_eval.py::TestAlignment::test_complex_series_frame_alignment[python-python-s-i-dt-s1] 423s 0.01s call tests/computation/test_eval.py::TestOperations::test_check_many_exprs[numexpr-pandas] 423s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[python-pandas-dt-dt-i-i] 423s 0.01s call tests/computation/test_eval.py::TestEval::test_chained_cmp_op[float-DataFrameNaN-Series-python-pandas-<-<] 423s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[python-python-dt-dt-i-dt] 423s 0.01s call tests/computation/test_eval.py::TestAlignment::test_complex_series_frame_alignment[python-pandas-dt-s-i-s0] 423s ========== 11124 passed, 33 xfailed, 2 xpassed, 2 warnings in 57.79s =========== 425s rdjoqkol test state = true 425s + echo 'rdjoqkol test state = true' 425s + for TEST_SUBSET in $modpath/tests/* 425s + echo /usr/lib/python3/dist-packages/pandas/tests/config 425s + grep -q -e __pycache__ 425s + PANDAS_CI=1 425s + LC_ALL=C.UTF-8 425s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/config 426s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 426s 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" 426s 426s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 426s ============================= test session starts ============================== 426s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 426s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 426s rootdir: /usr/lib/python3/dist-packages/pandas 426s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 426s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 426s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 426s collected 50 items 426s 426s ../../../usr/lib/python3/dist-packages/pandas/tests/config/test_config.py ..................... 426s ../../../usr/lib/python3/dist-packages/pandas/tests/config/test_localization.py ............................. 426s 426s =============================== warnings summary =============================== 426s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 426s /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-2wcsudzo' 426s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 426s 426s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 426s /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-_gn08dlf' 426s session.config.cache.set(STEPWISE_CACHE_DIR, []) 426s 426s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 426s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 426s ============================= slowest 30 durations ============================= 426s 0.03s call tests/config/test_localization.py::test_get_locales_prefix 426s 426s (29 durations < 0.005s hidden. Use -vv to show these durations.) 426s ======================== 50 passed, 2 warnings in 0.63s ======================== 426s + echo 'rdjoqkol test state = true' 426s rdjoqkol test state = true 426s + for TEST_SUBSET in $modpath/tests/* 426s + echo /usr/lib/python3/dist-packages/pandas/tests/construction 426s + grep -q -e __pycache__ 426s + PANDAS_CI=1 426s + LC_ALL=C.UTF-8 426s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/construction 427s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 427s 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" 427s 427s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 427s ============================= test session starts ============================== 427s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 427s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 427s rootdir: /usr/lib/python3/dist-packages/pandas 427s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 427s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 427s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 427s collected 1 item 427s 428s ../../../usr/lib/python3/dist-packages/pandas/tests/construction/test_extract_array.py . 428s 428s =============================== warnings summary =============================== 428s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 428s /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-sae1w978' 428s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 428s 428s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 428s /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-mi7u_x7e' 428s session.config.cache.set(STEPWISE_CACHE_DIR, []) 428s 428s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 428s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 428s ============================= slowest 30 durations ============================= 428s 428s (3 durations < 0.005s hidden. Use -vv to show these durations.) 428s ======================== 1 passed, 2 warnings in 0.09s ========================= 428s + echo 'rdjoqkol test state = true' 428s rdjoqkol test state = true 428s + for TEST_SUBSET in $modpath/tests/* 428s + echo /usr/lib/python3/dist-packages/pandas/tests/copy_view 428s + grep -q -e __pycache__ 428s + PANDAS_CI=1 428s + LC_ALL=C.UTF-8 428s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/copy_view 429s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 429s 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" 429s 429s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 430s ============================= test session starts ============================== 430s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 430s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 430s rootdir: /usr/lib/python3/dist-packages/pandas 430s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 430s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 430s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 430s collected 793 items 430s 430s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/index/test_datetimeindex.py ...... 430s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/index/test_index.py ..................... 430s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/index/test_periodindex.py .. 430s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/index/test_timedeltaindex.py .. 430s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_array.py ............. 430s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_astype.py .....ss...s..........s.. 430s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_chained_assignment_deprecation.py ............... 430s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_clip.py ...... 430s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_constructors.py ............................................................................ 430s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_core_functionalities.py ....... 430s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_functions.py .................... 431s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_indexing.py ....................................................................................s.....s........................................................................................................................................ 431s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_internals.py ..................... 431s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_interp_fillna.py ...................................................... 431s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_methods.py ........................................................................................................................................................................................................................................................ 432s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_replace.py ........................................ 432s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_setitem.py ......... 432s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_util.py .. 432s 432s =============================== warnings summary =============================== 432s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 432s /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-66k74jtr' 432s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 432s 432s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 432s /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-pe2dvmlg' 432s session.config.cache.set(STEPWISE_CACHE_DIR, []) 432s 432s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 432s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 432s ============================= slowest 30 durations ============================= 432s 0.02s call tests/copy_view/test_internals.py::test_exponential_backoff 432s 0.01s call tests/copy_view/test_indexing.py::test_midx_read_only_bool_indexer 432s 432s (28 durations < 0.005s hidden. Use -vv to show these durations.) 432s ================== 787 passed, 6 skipped, 2 warnings in 3.04s ================== 432s + echo 'rdjoqkol test state = true' 432s rdjoqkol test state = true 432s + for TEST_SUBSET in $modpath/tests/* 432s + echo /usr/lib/python3/dist-packages/pandas/tests/dtypes 432s + grep -q -e __pycache__ 432s + PANDAS_CI=1 432s + LC_ALL=C.UTF-8 432s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/dtypes 433s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 433s 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" 433s 433s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 434s ============================= test session starts ============================== 434s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 434s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 434s rootdir: /usr/lib/python3/dist-packages/pandas 434s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 434s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 434s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 434s collected 5628 items 434s 434s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_can_hold_element.py ........... 434s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_construct_from_scalar.py .... 434s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_construct_ndarray.py ....... 434s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_construct_object_arr.py ....................................... 434s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_dict_compat.py . 434s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_downcast.py ................................... 435s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_find_common_type.py .......................................................................................... 435s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_infer_datetimelike.py ... 435s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_infer_dtype.py .................................................................... 435s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_maybe_box_native.py ................ 439s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_promote.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 439s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_common.py .............................................................................................................................................................................s...................................................................................................................................................................................................................................................................... 439s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_concat.py .... 439s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_dtypes.py ........................................................................................................................................................................................................................................................................................... 440s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_generic.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 441s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_inference.py .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ssssssss....................................................... 441s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_missing.py ..........................................................................................................xxxx............................................................................................................................................................................................................. 441s 441s =============================== warnings summary =============================== 441s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 441s /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-sdub9la6' 441s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 441s 441s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 441s /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-979u9jnl' 441s session.config.cache.set(STEPWISE_CACHE_DIR, []) 441s 441s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 441s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 441s ============================= slowest 30 durations ============================= 441s 0.10s call tests/dtypes/test_common.py::test_is_sparse[True] 441s 0.07s call tests/dtypes/test_inference.py::TestInference::test_maybe_convert_objects_mixed_datetimes 441s 0.03s teardown tests/dtypes/test_missing.py::TestIsValidNAForDtype::test_is_valid_na_for_dtype_categorical 441s 0.01s call tests/dtypes/cast/test_promote.py::test_maybe_promote_any_numpy_dtype_with_datetimetz[int32-'UTC-02:15'-datetime.datetime] 441s 0.01s setup tests/dtypes/test_generic.py::TestABCClasses::test_abc_pairs_instance_check[ABCPeriodIndex-_7-ABCTimedeltaIndex-inst3] 441s 0.01s setup tests/dtypes/cast/test_promote.py::test_maybe_promote_any_with_datetime64[bytes0-pd.Timestamp] 441s 0.01s call tests/dtypes/test_inference.py::TestInference::test_maybe_convert_objects_itemsize[(1+1j)-(1+0j)] 441s 0.01s setup tests/dtypes/cast/test_promote.py::test_maybe_promote_object_with_any[object1-float64] 441s 0.01s call tests/dtypes/cast/test_promote.py::test_maybe_promote_any_numpy_dtype_with_datetimetz[m8[ns]-'UTC'-datetime.datetime] 441s 0.01s setup tests/dtypes/test_missing.py::TestLibMissing::test_checknull_old_na_vals[value17] 441s 0.01s call tests/dtypes/cast/test_can_hold_element.py::test_can_hold_element_range[uint8] 441s 0.01s call tests/dtypes/cast/test_can_hold_element.py::test_can_hold_element_range[uint16] 441s 0.01s call tests/dtypes/cast/test_can_hold_element.py::test_can_hold_element_range[uint32] 441s 0.01s call tests/dtypes/cast/test_can_hold_element.py::test_can_hold_element_range[int16] 441s 0.01s call tests/dtypes/cast/test_can_hold_element.py::test_can_hold_element_range[uint64] 441s 0.01s call tests/dtypes/cast/test_can_hold_element.py::test_can_hold_element_range[int8] 441s 0.01s call tests/dtypes/cast/test_can_hold_element.py::test_can_hold_element_range[int] 441s 0.01s call tests/dtypes/cast/test_can_hold_element.py::test_can_hold_element_range[int32] 441s 0.01s call tests/dtypes/cast/test_can_hold_element.py::test_can_hold_element_range[int64] 441s 441s (11 durations < 0.005s hidden. Use -vv to show these durations.) 441s ============ 5615 passed, 9 skipped, 4 xfailed, 2 warnings in 8.70s ============ 442s + echo 'rdjoqkol test state = true' 442s + for TEST_SUBSET in $modpath/tests/* 442s + echo /usr/lib/python3/dist-packages/pandas/tests/extension 442s + grep -q -e __pycache__ 442s rdjoqkol test state = true 442s + PANDAS_CI=1 442s + LC_ALL=C.UTF-8 442s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/extension 443s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 443s 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" 443s 443s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 447s ============================= test session starts ============================== 447s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 447s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 447s rootdir: /usr/lib/python3/dist-packages/pandas 447s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 447s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 447s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 447s collected 16808 items / 1 skipped 447s 447s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/array_with_attr/test_array_with_attr.py . 451s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/decimal/test_decimal.py ssssssssssssssssssssssssssssssssssss....................................x.................................................................................................................................................................................................................................................................................................................................xx............................................................s............................xxxxxxxxss..............xxssxxss................................................xxx..................... 467s ../../../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. 467s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/list/test_list.py . 470s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_categorical.py ssssssssssssssssssssssssssssssssssss....................................x..................................................................................................ssssssssssssssssssssssss...................................s.........................................................................................................................ss.................................................................................................xx...........................................................s............x..sxx................x.............xxxxxssssssssssssssssssssssssssssssssssss.. 470s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_common.py ............ 472s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_datetime.py ........................ssss............................................x..............................................................................................ssssssssssssssssssssssss.................................................................s......................................................................................................................................................................................xx..............................................xx...........................................................s............................................ssss......... 472s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_extension.py .............. 474s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_interval.py ssssssssssssssssssssssssssssssssssss....................................x..................................................................................................ssssssssssssssssssssssss.................................................................s...............................................................................................................................ss......................................................xx..............................................xx............................................................s............x. 494s ../../../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 501s ../../../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.. 505s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_period.py ..........................................ssss........ssss.....................................................................................x...x..................................................................................................................................................................................................ssssssssssssssssssssssssssssssssssssssssssssssss..................................................................................................................................ss........................................................................................................................................................................................................................................................................................................................................................................................................................................................................xxxx.......................................................................................................................s.s............................................................................ssss........ssss................ 518s ../../../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. 524s ../../../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 524s 524s =============================== warnings summary =============================== 524s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 524s /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-ns5ocmcj' 524s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 524s 524s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 524s /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-o693exdv' 524s session.config.cache.set(STEPWISE_CACHE_DIR, []) 524s 524s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 524s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 524s ============================= slowest 30 durations ============================= 524s 0.21s call tests/extension/test_masked.py::TestMaskedArrays::test_setitem_loc_scalar_mixed[Int16Dtype] 524s 0.15s call tests/extension/json/test_json.py::TestJSONArray::test_unary_ufunc_dunder_equivalence[negative] 524s 0.07s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[0-series-index2] 524s 0.07s teardown tests/extension/test_string.py::test_searchsorted_with_na_raises[False-False-pyarrow_numpy] 524s 0.07s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[nan-series-index2] 524s 0.06s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[0-series-index3] 524s 0.06s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[nan-series-index3] 524s 0.06s call tests/extension/decimal/test_decimal.py::TestDecimalArray::test_arith_series_with_array[__rpow__] 524s 0.06s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[UInt64Dtype-series-index2] 524s 0.05s call tests/extension/test_string.py::TestStringArray::test_unstack[True-python-series-index2] 524s 0.05s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Float32Dtype-series-index3] 524s 0.05s call tests/extension/test_period.py::TestPeriodArray::test_unstack[2D-series-index3] 524s 0.05s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Float64Dtype-series-index2] 524s 0.05s call tests/extension/test_string.py::TestStringArray::test_unstack[False-python-series-index2] 524s 0.05s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[BooleanDtype-series-index2] 524s 0.05s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Float32Dtype-series-index2] 524s 0.05s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[UInt16Dtype-series-index2] 524s 0.05s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Int8Dtype-series-index3] 524s 0.05s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Int8Dtype-series-index2] 524s 0.05s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[UInt32Dtype-series-index2] 524s 0.05s call tests/extension/test_string.py::TestStringArray::test_unstack[False-python-series-index3] 524s 0.05s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Float64Dtype-series-index3] 524s 0.05s call tests/extension/test_string.py::TestStringArray::test_unstack[True-python-series-index3] 524s 0.05s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[nan-frame-index2] 524s 0.05s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Int16Dtype-series-index2] 524s 0.05s call tests/extension/test_interval.py::TestIntervalArray::test_unstack[series-index2] 524s 0.05s call tests/extension/test_numpy.py::TestNumpyExtensionArray::test_unstack[float-series-index2] 524s 0.05s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[BooleanDtype-series-index3] 524s 0.05s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[0-frame-index2] 524s 0.05s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[UInt64Dtype-series-index3] 524s === 12106 passed, 4371 skipped, 332 xfailed, 2 warnings in 80.72s (0:01:20) ==== 526s rdjoqkol test state = true 526s + echo 'rdjoqkol test state = true' 526s + for TEST_SUBSET in $modpath/tests/* 526s + echo /usr/lib/python3/dist-packages/pandas/tests/frame 526s + grep -q -e __pycache__ 526s + PANDAS_CI=1 526s + LC_ALL=C.UTF-8 526s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/frame 526s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 526s 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" 526s 526s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 532s ============================= test session starts ============================== 532s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 532s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 532s rootdir: /usr/lib/python3/dist-packages/pandas 532s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 532s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 532s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 532s collected 11172 items / 433 deselected / 1 skipped / 10739 selected 532s 532s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/constructors/test_from_dict.py .............. 532s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/constructors/test_from_records.py ........................... 532s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_coercion.py .......x.x. 532s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_delitem.py .... 532s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_get.py .... 532s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_get_value.py .. 533s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_getitem.py ........................................ 535s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_indexing.py ...................................................................................................................................................................................................................................sss................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 535s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_insert.py ....... 535s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_mask.py ........... 535s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_set_value.py ... 535s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_setitem.py ........................................................................................................s..........................................................................................xxx...........................x..x..x..x........ 535s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_take.py .... 538s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_where.py ............................................................................................................................................. 538s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_xs.py .............................. 538s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_add_prefix_suffix.py ... 539s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_align.py ........................................................................................................................................................................................................................................................................................................................................................................................................................ 539s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_asfreq.py ........................................ 539s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_asof.py ........... 539s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_assign.py ..... 540s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_astype.py .......................................................................................................................s....s........................................................................................................ss.....ssssssssss 540s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_at_time.py ...................... 540s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_between_time.py .............................. 540s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_clip.py ..................... 540s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_combine.py ..... 541s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_combine_first.py ..................................s............................... 541s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_compare.py ......................... 541s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_convert_dtypes.py ..ssss..ssss.sss.. 541s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_copy.py ..... 541s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_count.py .. 542s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_cov_corr.py .............................................................s............ 542s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_describe.py ...............................................s 542s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_diff.py .............................................. 543s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_dot.py ................sss 543s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_drop.py ......................................................................... 543s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_drop_duplicates.py ..................................... 543s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_droplevel.py .. 543s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_dropna.py ................... 543s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_dtypes.py ........ 543s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_duplicated.py .......xxx........... 543s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_equals.py ... 543s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_explode.py ..................... 544s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_fillna.py ................................................................. 544s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_filter.py ........... 544s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_first_and_last.py ............. 544s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_first_valid_index.py ............... 544s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_get_numeric_data.py .... 545s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_head_tail.py .................................................................. 545s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_infer_objects.py . 546s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_info.py ..........................x......s...... 546s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_interpolate.py ...................................................................ssssssssss 546s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_is_homogeneous_dtype.py ....... 546s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_isetitem.py ... 546s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_isin.py ................. 546s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_iterrows.py . 546s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_join.py ...........s................... 546s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_map.py ......................... 546s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_matmul.py .. 547s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_nlargest.py .........................................................................................................................................................................................................................................................X.....X.....X.....X.......X..... 547s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_pct_change.py ............................. 547s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_pipe.py ...... 547s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_pop.py ... 550s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_quantile.py ........................................................................xx..........xx..........xx..........xx.................. 552s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_rank.py .........................................................................................................................ss 552s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_reindex.py ................................................................................................................................................. 552s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_reindex_like.py ..... 552s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_rename.py ......................... 553s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_rename_axis.py ......... 553s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_reorder_levels.py ... 553s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_replace.py ...................ss.................ssss....ssss................................................................................................................................................................. 554s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_reset_index.py ................................................................................................................................ 554s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_round.py ......... 554s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_sample.py .......................................................... 554s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_select_dtypes.py ..................................s...... 554s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_set_axis.py .............. 557s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_set_index.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 560s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_shift.py ...................................................................................x.x.x.x.x.xxxx........ 560s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_size.py ..... 561s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_sort_index.py ................................................................. 561s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_sort_values.py ...................................................X...............................XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX..... 561s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_swapaxes.py .... 561s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_swaplevel.py . 563s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_csv.py ............................................................................. 564s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_dict.py ...................................................................................................... 564s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_dict_of_blocks.py ... 564s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_numpy.py .... 564s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_period.py ...................................................................... 564s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_records.py ................................... 564s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_timestamp.py ...................................................................... 564s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_transpose.py ................... 564s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_truncate.py ........................................................................................ 564s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_tz_convert.py ........... 564s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_tz_localize.py ......... 564s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_update.py .............. 564s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_value_counts.py ................................. 565s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_values.py ............... 565s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_alter_axes.py .. 565s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_api.py ......................ss.......... 568s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_arithmetic.py ..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x..........x................................................................................................................................ 568s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_block_internals.py ................... 571s ../../../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................................ 571s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_cumulative.py ....... 572s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_iteration.py .................... 572s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_logical_ops.py ................. 572s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_nonunique_indexes.py ................ 572s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_npfuncs.py .... 574s ../../../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. 579s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_reductions.py ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s....................................................................................................x.............x............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 579s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_repr.py ..........................................ssss................ 587s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_stack_unstack.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 587s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_subclass.py .................................................... 589s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_ufunc.py ....xx.........xxxxxxxx.xx....s. 589s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_unary.py .................. 589s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_validate.py ............................ 589s 589s =============================== warnings summary =============================== 589s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 589s /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-k6xy8xx_' 589s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 589s 589s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 589s /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-0czvi2jx' 589s session.config.cache.set(STEPWISE_CACHE_DIR, []) 589s 589s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 589s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 589s ============================= slowest 30 durations ============================= 589s 1.73s call tests/frame/indexing/test_where.py::test_where_inplace_casting 589s 1.40s call tests/frame/methods/test_rank.py::TestRank::test_pct_max_many_rows 589s 0.82s call tests/frame/test_api.py::TestDataFrameMisc::test_inspect_getmembers 589s 0.45s call tests/frame/methods/test_cov_corr.py::TestDataFrameCorr::test_corr_scipy_method[kendall] 589s 0.44s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_chunking[10000] 589s 0.42s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_chunking[50000] 589s 0.42s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_chunking[100000] 589s 0.35s call tests/frame/test_reductions.py::test_numeric_ea_axis_1[False-UInt64-2-idxmax] 589s 0.33s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_with_dst_transitions_with_pickle 589s 0.28s 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] 589s 0.25s call tests/frame/methods/test_info.py::test_info_verbose_check_header_separator_body 589s 0.20s call tests/frame/methods/test_cov_corr.py::TestDataFrameCorrWith::test_corrwith[Float64] 589s 0.15s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack[False] 589s 0.14s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack_order_with_unsorted_levels_multi_row[False] 589s 0.14s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_dups_cols 589s 0.12s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack[True] 589s 0.11s call tests/frame/methods/test_at_time.py::TestAtTime::test_at_time_axis[0] 589s 0.11s call tests/frame/methods/test_at_time.py::TestAtTime::test_at_time_axis[index] 589s 0.10s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack_order_with_unsorted_levels_multi_row[True] 589s 0.10s call tests/frame/test_repr.py::TestDataFrameRepr::test_repr_to_string 589s 0.10s call tests/frame/test_repr.py::TestDataFrameRepr::test_repr_bytes_61_lines 589s 0.08s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack_unstack_multiple[False] 589s 0.08s call tests/frame/methods/test_interpolate.py::TestDataFrameInterpolate::test_interp_string_axis[index-0] 589s 0.08s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack_unstack_multiple[True] 589s 0.07s call tests/frame/test_query_eval.py::TestDataFrameQueryNumExprPandas::test_nested_scope 589s 0.07s call tests/frame/test_stack_unstack.py::TestDataFrameReshape::test_stack_int_level_names[False] 589s 0.07s call tests/frame/methods/test_interpolate.py::TestDataFrameInterpolate::test_interp_string_axis[columns-1] 589s 0.06s call tests/frame/test_block_internals.py::TestDataFrameBlockInternals::test_strange_column_corruption_issue 589s 0.06s call tests/frame/test_iteration.py::TestIteration::test_itertuples_py2_3_field_limit_namedtuple[False-1024] 589s 0.06s call tests/frame/methods/test_duplicated.py::test_duplicated_implemented_no_recursion 589s = 10438 passed, 206 skipped, 433 deselected, 58 xfailed, 38 xpassed, 2 warnings in 62.51s (0:01:02) = 591s + echo 'rdjoqkol test state = true' 591s + for TEST_SUBSET in $modpath/tests/* 591s rdjoqkol test state = true 591s + echo /usr/lib/python3/dist-packages/pandas/tests/generic 591s + grep -q -e __pycache__ 591s + PANDAS_CI=1 591s + LC_ALL=C.UTF-8 591s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/generic 592s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 592s 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" 592s 592s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 592s ============================= test session starts ============================== 592s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 592s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 592s rootdir: /usr/lib/python3/dist-packages/pandas 592s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 592s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 592s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 592s collected 1249 items 592s 592s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_duplicate_labels.py ..........xx...........x.......xx.xxx................x................ 597s ../../../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. 597s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_frame.py ............... 597s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_generic.py ................................................................................. 598s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_label_or_level_utils.py ....................................................................... 598s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_series.py ................... 598s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py expected 598s bar a b c d e f g h 598s foo 598s pandas_0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s pandas_1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s pandas_2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='object', name='foo') 598s bar 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s actual 598s Size: 236B 598s Dimensions: (foo: 4) 598s Coordinates: 598s * foo (foo) object 32B 'pandas_0' 'pandas_1' 'pandas_2' 'pandas_3' 598s Data variables: 598s a (foo) object 32B 'a' 'b' 'c' 'd' 598s b (foo) int64 32B 1 2 3 4 598s c (foo) uint8 4B 3 4 5 6 598s d (foo) float64 32B 4.0 5.0 6.0 7.0 598s e (foo) bool 4B True False True False 598s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 598s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 598s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 598s a b c d e f g h 598s foo 598s pandas_0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s pandas_1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s pandas_2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='object', name='foo') 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s Xexpected 598s bar a b c d e f g h 598s foo 598s 2020-01-01 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 2020-01-02 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2020-01-03 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 2020-01-04 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s DatetimeIndex(['2020-01-01', '2020-01-02', '2020-01-03', '2020-01-04'], dtype='datetime64[ns]', name='foo', freq='D') 598s bar 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s actual 598s Size: 236B 598s Dimensions: (foo: 4) 598s Coordinates: 598s * foo (foo) datetime64[ns] 32B 2020-01-01 2020-01-02 ... 2020-01-04 598s Data variables: 598s a (foo) object 32B 'a' 'b' 'c' 'd' 598s b (foo) int64 32B 1 2 3 4 598s c (foo) uint8 4B 3 4 5 6 598s d (foo) float64 32B 4.0 5.0 6.0 7.0 598s e (foo) bool 4B True False True False 598s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 598s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 598s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 598s a b c d e f g h 598s foo 598s 2020-01-01 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 2020-01-02 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2020-01-03 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 2020-01-04 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s DatetimeIndex(['2020-01-01', '2020-01-02', '2020-01-03', '2020-01-04'], dtype='datetime64[ns]', name='foo', freq='D') 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s Xexpected 598s bar a b c ... f g h 598s foo ... 598s 2020-01-01 00:00:00-08:00 a 1 3 ... a 2013-01-01 2013-01-01 00:00:00-05:00 598s 2020-01-02 00:00:00-08:00 b 2 4 ... b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2020-01-03 00:00:00-08:00 c 3 5 ... c 2013-01-03 2013-01-03 00:00:00-05:00 598s 2020-01-04 00:00:00-08:00 d 4 6 ... d 2013-01-04 2013-01-04 00:00:00-05:00 598s 598s [4 rows x 8 columns] 598s DatetimeIndex(['2020-01-01 00:00:00-08:00', '2020-01-02 00:00:00-08:00', 598s '2020-01-03 00:00:00-08:00', '2020-01-04 00:00:00-08:00'], 598s dtype='datetime64[ns, US/Pacific]', name='foo', freq='D') 598s bar 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s actual 598s Size: 236B 598s Dimensions: (foo: 4) 598s Coordinates: 598s * foo (foo) object 32B 1577865600000000000 ... 1578124800000000000 598s Data variables: 598s a (foo) object 32B 'a' 'b' 'c' 'd' 598s b (foo) int64 32B 1 2 3 4 598s c (foo) uint8 4B 3 4 5 6 598s d (foo) float64 32B 4.0 5.0 6.0 7.0 598s e (foo) bool 4B True False True False 598s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 598s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 598s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 598s a b c ... f g h 598s foo ... 598s 2020-01-01 00:00:00-08:00 a 1 3 ... NaN 2013-01-01 2013-01-01 00:00:00-05:00 598s 2020-01-02 00:00:00-08:00 b 2 4 ... NaN 2013-01-02 2013-01-02 00:00:00-05:00 598s 2020-01-03 00:00:00-08:00 c 3 5 ... NaN 2013-01-03 2013-01-03 00:00:00-05:00 598s 2020-01-04 00:00:00-08:00 d 4 6 ... NaN 2013-01-04 2013-01-04 00:00:00-05:00 598s 598s [4 rows x 8 columns] 598s Index([2020-01-01 00:00:00-08:00, 2020-01-02 00:00:00-08:00, 598s 2020-01-03 00:00:00-08:00, 2020-01-04 00:00:00-08:00], 598s dtype='object', name='foo') 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s xexpected 598s bar a b c d e f g h 598s foo 598s 2020-01-01 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 2020-01-02 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2020-01-03 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 2020-01-04 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s PeriodIndex(['2020-01-01', '2020-01-02', '2020-01-03', '2020-01-04'], dtype='period[D]', name='foo') 598s bar 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s actual 598s Size: 236B 598s Dimensions: (foo: 4) 598s Coordinates: 598s * foo (foo) object 32B 2020-01-01 2020-01-02 2020-01-03 2020-01-04 598s Data variables: 598s a (foo) object 32B 'a' 'b' 'c' 'd' 598s b (foo) int64 32B 1 2 3 4 598s c (foo) uint8 4B 3 4 5 6 598s d (foo) float64 32B 4.0 5.0 6.0 7.0 598s e (foo) bool 4B True False True False 598s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 598s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 598s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 598s a b c d e f g h 598s foo 598s 2020-01-01 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 2020-01-02 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2020-01-03 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 2020-01-04 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s PeriodIndex(['2020-01-01', '2020-01-02', '2020-01-03', '2020-01-04'], dtype='period[D]', name='foo') 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s Xexpected 598s bar a b c d e f g h 598s foo 598s 1 days a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 2 days b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 3 days c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 4 days d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s TimedeltaIndex(['1 days', '2 days', '3 days', '4 days'], dtype='timedelta64[ns]', name='foo', freq='D') 598s bar 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s actual 598s Size: 236B 598s Dimensions: (foo: 4) 598s Coordinates: 598s * foo (foo) timedelta64[ns] 32B 1 days 2 days 3 days 4 days 598s Data variables: 598s a (foo) object 32B 'a' 'b' 'c' 'd' 598s b (foo) int64 32B 1 2 3 4 598s c (foo) uint8 4B 3 4 5 6 598s d (foo) float64 32B 4.0 5.0 6.0 7.0 598s e (foo) bool 4B True False True False 598s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 598s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 598s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 598s a b c d e f g h 598s foo 598s 1 days a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 2 days b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 3 days c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 4 days d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s TimedeltaIndex(['1 days', '2 days', '3 days', '4 days'], dtype='timedelta64[ns]', name='foo', freq='D') 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s Xexpected 598s bar a b c d e f g h 598s foo 598s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s RangeIndex(start=0, stop=4, step=1, name='foo') 598s bar 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s actual 598s Size: 236B 598s Dimensions: (foo: 4) 598s Coordinates: 598s * foo (foo) int64 32B 0 1 2 3 598s Data variables: 598s a (foo) object 32B 'a' 'b' 'c' 'd' 598s b (foo) int64 32B 1 2 3 4 598s c (foo) uint8 4B 3 4 5 6 598s d (foo) float64 32B 4.0 5.0 6.0 7.0 598s e (foo) bool 4B True False True False 598s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 598s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 598s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 598s a b c d e f g h 598s foo 598s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s RangeIndex(start=0, stop=4, step=1, name='foo') 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s Xexpected 598s bar a b c d e f g h 598s foo 598s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index([0, 1, 2, 3], dtype='int8', name='foo') 598s bar 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s actual 598s Size: 208B 598s Dimensions: (foo: 4) 598s Coordinates: 598s * foo (foo) int8 4B 0 1 2 3 598s Data variables: 598s a (foo) object 32B 'a' 'b' 'c' 'd' 598s b (foo) int64 32B 1 2 3 4 598s c (foo) uint8 4B 3 4 5 6 598s d (foo) float64 32B 4.0 5.0 6.0 7.0 598s e (foo) bool 4B True False True False 598s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 598s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 598s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 598s a b c d e f g h 598s foo 598s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index([0, 1, 2, 3], dtype='int8', name='foo') 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s Xexpected 598s bar a b c d e f g h 598s foo 598s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index([0, 1, 2, 3], dtype='int16', name='foo') 598s bar 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s actual 598s Size: 212B 598s Dimensions: (foo: 4) 598s Coordinates: 598s * foo (foo) int16 8B 0 1 2 3 598s Data variables: 598s a (foo) object 32B 'a' 'b' 'c' 'd' 598s b (foo) int64 32B 1 2 3 4 598s c (foo) uint8 4B 3 4 5 6 598s d (foo) float64 32B 4.0 5.0 6.0 7.0 598s e (foo) bool 4B True False True False 598s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 598s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 598s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 598s a b c d e f g h 598s foo 598s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index([0, 1, 2, 3], dtype='int16', name='foo') 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s Xexpected 598s bar a b c d e f g h 598s foo 598s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index([0, 1, 2, 3], dtype='int32', name='foo') 598s bar 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s actual 598s Size: 220B 598s Dimensions: (foo: 4) 598s Coordinates: 598s * foo (foo) int32 16B 0 1 2 3 598s Data variables: 598s a (foo) object 32B 'a' 'b' 'c' 'd' 598s b (foo) int64 32B 1 2 3 4 598s c (foo) uint8 4B 3 4 5 6 598s d (foo) float64 32B 4.0 5.0 6.0 7.0 598s e (foo) bool 4B True False True False 598s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 598s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 598s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 598s a b c d e f g h 598s foo 598s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index([0, 1, 2, 3], dtype='int32', name='foo') 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s Xexpected 598s bar a b c d e f g h 598s foo 598s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index([0, 1, 2, 3], dtype='int64', name='foo') 598s bar 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s actual 598s Size: 236B 598s Dimensions: (foo: 4) 598s Coordinates: 598s * foo (foo) int64 32B 0 1 2 3 598s Data variables: 598s a (foo) object 32B 'a' 'b' 'c' 'd' 598s b (foo) int64 32B 1 2 3 4 598s c (foo) uint8 4B 3 4 5 6 598s d (foo) float64 32B 4.0 5.0 6.0 7.0 598s e (foo) bool 4B True False True False 598s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 598s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 598s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 598s a b c d e f g h 598s foo 598s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index([0, 1, 2, 3], dtype='int64', name='foo') 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s Xexpected 598s bar a b c d e f g h 598s foo 598s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index([0, 1, 2, 3], dtype='uint8', name='foo') 598s bar 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s actual 598s Size: 208B 598s Dimensions: (foo: 4) 598s Coordinates: 598s * foo (foo) uint8 4B 0 1 2 3 598s Data variables: 598s a (foo) object 32B 'a' 'b' 'c' 'd' 598s b (foo) int64 32B 1 2 3 4 598s c (foo) uint8 4B 3 4 5 6 598s d (foo) float64 32B 4.0 5.0 6.0 7.0 598s e (foo) bool 4B True False True False 598s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 598s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 598s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 598s a b c d e f g h 598s foo 598s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index([0, 1, 2, 3], dtype='uint8', name='foo') 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s Xexpected 598s bar a b c d e f g h 598s foo 598s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index([0, 1, 2, 3], dtype='uint16', name='foo') 598s bar 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s actual 598s Size: 212B 598s Dimensions: (foo: 4) 598s Coordinates: 598s * foo (foo) uint16 8B 0 1 2 3 598s Data variables: 598s a (foo) object 32B 'a' 'b' 'c' 'd' 598s b (foo) int64 32B 1 2 3 4 598s c (foo) uint8 4B 3 4 5 6 598s d (foo) float64 32B 4.0 5.0 6.0 7.0 598s e (foo) bool 4B True False True False 598s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 598s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 598s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 598s a b c d e f g h 598s foo 598s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index([0, 1, 2, 3], dtype='uint16', name='foo') 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s Xexpected 598s bar a b c d e f g h 598s foo 598s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index([0, 1, 2, 3], dtype='uint32', name='foo') 598s bar 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s actual 598s Size: 220B 598s Dimensions: (foo: 4) 598s Coordinates: 598s * foo (foo) uint32 16B 0 1 2 3 598s Data variables: 598s a (foo) object 32B 'a' 'b' 'c' 'd' 598s b (foo) int64 32B 1 2 3 4 598s c (foo) uint8 4B 3 4 5 6 598s d (foo) float64 32B 4.0 5.0 6.0 7.0 598s e (foo) bool 4B True False True False 598s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 598s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 598s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 598s a b c d e f g h 598s foo 598s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index([0, 1, 2, 3], dtype='uint32', name='foo') 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s Xexpected 598s bar a b c d e f g h 598s foo 598s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index([0, 1, 2, 3], dtype='uint64', name='foo') 598s bar 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s actual 598s Size: 236B 598s Dimensions: (foo: 4) 598s Coordinates: 598s * foo (foo) uint64 32B 0 1 2 3 598s Data variables: 598s a (foo) object 32B 'a' 'b' 'c' 'd' 598s b (foo) int64 32B 1 2 3 4 598s c (foo) uint8 4B 3 4 5 6 598s d (foo) float64 32B 4.0 5.0 6.0 7.0 598s e (foo) bool 4B True False True False 598s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 598s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 598s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 598s a b c d e f g h 598s foo 598s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index([0, 1, 2, 3], dtype='uint64', name='foo') 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s Xexpected 598s bar a b c d e f g h 598s foo 598s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index([0.0, 1.0, 2.0, 3.0], dtype='float32', name='foo') 598s bar 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s actual 598s Size: 220B 598s Dimensions: (foo: 4) 598s Coordinates: 598s * foo (foo) float32 16B 0.0 1.0 2.0 3.0 598s Data variables: 598s a (foo) object 32B 'a' 'b' 'c' 'd' 598s b (foo) int64 32B 1 2 3 4 598s c (foo) uint8 4B 3 4 5 6 598s d (foo) float64 32B 4.0 5.0 6.0 7.0 598s e (foo) bool 4B True False True False 598s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 598s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 598s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 598s a b c d e f g h 598s foo 598s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index([0.0, 1.0, 2.0, 3.0], dtype='float32', name='foo') 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s Xexpected 598s bar a b c d e f g h 598s foo 598s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index([0.0, 1.0, 2.0, 3.0], dtype='float64', name='foo') 598s bar 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s actual 598s Size: 236B 598s Dimensions: (foo: 4) 598s Coordinates: 598s * foo (foo) float64 32B 0.0 1.0 2.0 3.0 598s Data variables: 598s a (foo) object 32B 'a' 'b' 'c' 'd' 598s b (foo) int64 32B 1 2 3 4 598s c (foo) uint8 4B 3 4 5 6 598s d (foo) float64 32B 4.0 5.0 6.0 7.0 598s e (foo) bool 4B True False True False 598s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 598s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 598s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 598s a b c d e f g h 598s foo 598s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index([0.0, 1.0, 2.0, 3.0], dtype='float64', name='foo') 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s Xexpected 598s bar a b c d e f g h 598s foo 598s True a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s False b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index([True, False, True, False], dtype='object', name='foo') 598s bar 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s actual 598s Size: 236B 598s Dimensions: (foo: 4) 598s Coordinates: 598s * foo (foo) object 32B True False True False 598s Data variables: 598s a (foo) object 32B 'a' 'b' 'c' 'd' 598s b (foo) int64 32B 1 2 3 4 598s c (foo) uint8 4B 3 4 5 6 598s d (foo) float64 32B 4.0 5.0 6.0 7.0 598s e (foo) bool 4B True False True False 598s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 598s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 598s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 598s a b c d e f g h 598s foo 598s True a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s True a 1 3 4.0 True c 2013-01-01 2013-01-01 00:00:00-05:00 598s False b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s False b 2 4 5.0 False d 2013-01-02 2013-01-02 00:00:00-05:00 598s True c 3 5 6.0 True a 2013-01-03 2013-01-03 00:00:00-05:00 598s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s False d 4 6 7.0 False b 2013-01-04 2013-01-04 00:00:00-05:00 598s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index([True, True, False, False, True, True, False, False], dtype='object', name='foo') 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s xexpected 598s bar a b c d e f g h 598s foo 598s True a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s False b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index([True, False, True, False], dtype='bool', name='foo') 598s bar 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s actual 598s Size: 208B 598s Dimensions: (foo: 4) 598s Coordinates: 598s * foo (foo) bool 4B True False True False 598s Data variables: 598s a (foo) object 32B 'a' 'b' 'c' 'd' 598s b (foo) int64 32B 1 2 3 4 598s c (foo) uint8 4B 3 4 5 6 598s d (foo) float64 32B 4.0 5.0 6.0 7.0 598s e (foo) bool 4B True False True False 598s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 598s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 598s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 598s a b c d e f g h 598s foo 598s True a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s True a 1 3 4.0 True c 2013-01-01 2013-01-01 00:00:00-05:00 598s False b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s False b 2 4 5.0 False d 2013-01-02 2013-01-02 00:00:00-05:00 598s True c 3 5 6.0 True a 2013-01-03 2013-01-03 00:00:00-05:00 598s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s False d 4 6 7.0 False b 2013-01-04 2013-01-04 00:00:00-05:00 598s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index([True, True, False, False, True, True, False, False], dtype='bool', name='foo') 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s xexpected 598s bar a b c d e f g h 598s foo 598s 0.0+0.0j a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 1.0+1.0j b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2.0+2.0j c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 3.0+3.0j d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index([0j, (1+1j), (2+2j), (3+3j)], dtype='complex64', name='foo') 598s bar 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s actual 598s Size: 236B 598s Dimensions: (foo: 4) 598s Coordinates: 598s * foo (foo) complex64 32B 0j (1+1j) (2+2j) (3+3j) 598s Data variables: 598s a (foo) object 32B 'a' 'b' 'c' 'd' 598s b (foo) int64 32B 1 2 3 4 598s c (foo) uint8 4B 3 4 5 6 598s d (foo) float64 32B 4.0 5.0 6.0 7.0 598s e (foo) bool 4B True False True False 598s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 598s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 598s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 598s a b c d e f g h 598s foo 598s 0.0+0.0j a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 1.0+1.0j b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2.0+2.0j c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 3.0+3.0j d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index([0j, (1+1j), (2+2j), (3+3j)], dtype='complex64', name='foo') 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s Xexpected 598s bar a b c d e f g h 598s foo 598s 0.0+0.0j a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 1.0+1.0j b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2.0+2.0j c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 3.0+3.0j d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index([0j, (1+1j), (2+2j), (3+3j)], dtype='complex128', name='foo') 598s bar 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 598s actual 598s Size: 268B 598s Dimensions: (foo: 4) 598s Coordinates: 598s * foo (foo) complex128 64B 0j (1+1j) (2+2j) (3+3j) 598s Data variables: 598s a (foo) object 32B 'a' 'b' 'c' 'd' 598s b (foo) int64 32B 1 2 3 4 598s c (foo) uint8 4B 3 4 5 6 598s d (foo) float64 32B 4.0 5.0 6.0 7.0 598s e (foo) bool 4B True False True False 598s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 598s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 598s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 598s a b c d e f g h 598s foo 598s 0.0+0.0j a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 598s 1.0+1.0j b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 598s 2.0+2.0j c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 598s 3.0+3.0j d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 598s Index([0j, (1+1j), (2+2j), (3+3j)], dtype='complex128', name='foo') 598s a object 598s b int64 598s c uint8 598s d float64 598s e bool 598s f category 598s g datetime64[ns] 598s h datetime64[ns, US/Eastern] 598s dtype: object 599s Xexpected 599s bar a b c d e f g h 599s foo 599s a a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 599s b b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 599s c c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 599s d d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 599s CategoricalIndex(['a', 'b', 'c', 'd'], categories=['a', 'b', 'c', 'd'], ordered=False, dtype='category', name='foo') 599s bar 599s a object 599s b int64 599s c uint8 599s d float64 599s e bool 599s f category 599s g datetime64[ns] 599s h datetime64[ns, US/Eastern] 599s dtype: object 599s actual 599s Size: 236B 599s Dimensions: (foo: 4) 599s Coordinates: 599s * foo (foo) object 32B 'a' 'b' 'c' 'd' 599s Data variables: 599s a (foo) object 32B 'a' 'b' 'c' 'd' 599s b (foo) int64 32B 1 2 3 4 599s c (foo) uint8 4B 3 4 5 6 599s d (foo) float64 32B 4.0 5.0 6.0 7.0 599s e (foo) bool 4B True False True False 599s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 599s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 599s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 599s a b c d e f g h 599s foo 599s a a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 599s b b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 599s c c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 599s d d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 599s Index(['a', 'b', 'c', 'd'], dtype='object', name='foo') 599s a object 599s b int64 599s c uint8 599s d float64 599s e bool 599s f category 599s g datetime64[ns] 599s h datetime64[ns, US/Eastern] 599s dtype: object 599s xexpected 599s bar a b c d e f g h 599s foo 599s (0.0, 1.0] a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 599s (1.0, 2.0] b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 599s (2.0, 3.0] c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 599s (3.0, 4.0] d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 599s IntervalIndex([(0.0, 1.0], (1.0, 2.0], (2.0, 3.0], (3.0, 4.0]], dtype='interval[float64, right]', name='foo') 599s bar 599s a object 599s b int64 599s c uint8 599s d float64 599s e bool 599s f category 599s g datetime64[ns] 599s h datetime64[ns, US/Eastern] 599s dtype: object 599s actual 599s Size: 236B 599s Dimensions: (foo: 4) 599s Coordinates: 599s * foo (foo) object 32B (0.0, 1.0] (1.0, 2.0] (2.0, 3.0] (3.0, 4.0] 599s Data variables: 599s a (foo) object 32B 'a' 'b' 'c' 'd' 599s b (foo) int64 32B 1 2 3 4 599s c (foo) uint8 4B 3 4 5 6 599s d (foo) float64 32B 4.0 5.0 6.0 7.0 599s e (foo) bool 4B True False True False 599s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 599s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 599s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 599s a b c d e f g h 599s foo 599s (0.0, 1.0] a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 599s (1.0, 2.0] b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 599s (2.0, 3.0] c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 599s (3.0, 4.0] d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 599s IntervalIndex([(0.0, 1.0], (1.0, 2.0], (2.0, 3.0], (3.0, 4.0]], dtype='interval[float64, right]', name='foo') 599s a object 599s b int64 599s c uint8 599s d float64 599s e bool 599s f category 599s g datetime64[ns] 599s h datetime64[ns, US/Eastern] 599s dtype: object 599s Xsexpected 599s bar a b c d e f g h 599s foo 599s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 599s 0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 599s 1 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 599s 1 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 599s Index([0, 0, 1, 1], dtype='int64', name='foo') 599s bar 599s a object 599s b int64 599s c uint8 599s d float64 599s e bool 599s f category 599s g datetime64[ns] 599s h datetime64[ns, US/Eastern] 599s dtype: object 599s actual 599s Size: 236B 599s Dimensions: (foo: 4) 599s Coordinates: 599s * foo (foo) int64 32B 0 0 1 1 599s Data variables: 599s a (foo) object 32B 'a' 'b' 'c' 'd' 599s b (foo) int64 32B 1 2 3 4 599s c (foo) uint8 4B 3 4 5 6 599s d (foo) float64 32B 4.0 5.0 6.0 7.0 599s e (foo) bool 4B True False True False 599s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 599s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 599s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 599s a b c d e f g h 599s foo 599s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 599s 0 a 1 3 4.0 True b 2013-01-01 2013-01-01 00:00:00-05:00 599s 0 b 2 4 5.0 False a 2013-01-02 2013-01-02 00:00:00-05:00 599s 0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 599s 1 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 599s 1 c 3 5 6.0 True d 2013-01-03 2013-01-03 00:00:00-05:00 599s 1 d 4 6 7.0 False c 2013-01-04 2013-01-04 00:00:00-05:00 599s 1 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 599s Index([0, 0, 0, 0, 1, 1, 1, 1], dtype='int64', name='foo') 599s a object 599s b int64 599s c uint8 599s d float64 599s e bool 599s f category 599s g datetime64[ns] 599s h datetime64[ns, US/Eastern] 599s dtype: object 599s xexpected 599s bar a b c d e f g h 599s foo 599s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 599s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 599s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 599s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 599s Index([0, 1, 2, 3], dtype='Int64', name='foo') 599s bar 599s a object 599s b int64 599s c uint8 599s d float64 599s e bool 599s f category 599s g datetime64[ns] 599s h datetime64[ns, US/Eastern] 599s dtype: object 599s actual 599s Size: 236B 599s Dimensions: (foo: 4) 599s Coordinates: 599s * foo (foo) object 32B 0 1 2 3 599s Data variables: 599s a (foo) object 32B 'a' 'b' 'c' 'd' 599s b (foo) int64 32B 1 2 3 4 599s c (foo) uint8 4B 3 4 5 6 599s d (foo) float64 32B 4.0 5.0 6.0 7.0 599s e (foo) bool 4B True False True False 599s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 599s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 599s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 599s a b c d e f g h 599s foo 599s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 599s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 599s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 599s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 599s Index([0, 1, 2, 3], dtype='object', name='foo') 599s a object 599s b int64 599s c uint8 599s d float64 599s e bool 599s f category 599s g datetime64[ns] 599s h datetime64[ns, US/Eastern] 599s dtype: object 599s xexpected 599s bar a b c d e f g h 599s foo 599s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 599s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 599s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 599s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 599s Index([0, 1, 2, 3], dtype='UInt16', name='foo') 599s bar 599s a object 599s b int64 599s c uint8 599s d float64 599s e bool 599s f category 599s g datetime64[ns] 599s h datetime64[ns, US/Eastern] 599s dtype: object 599s actual 599s Size: 236B 599s Dimensions: (foo: 4) 599s Coordinates: 599s * foo (foo) object 32B 0 1 2 3 599s Data variables: 599s a (foo) object 32B 'a' 'b' 'c' 'd' 599s b (foo) int64 32B 1 2 3 4 599s c (foo) uint8 4B 3 4 5 6 599s d (foo) float64 32B 4.0 5.0 6.0 7.0 599s e (foo) bool 4B True False True False 599s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 599s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 599s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 599s a b c d e f g h 599s foo 599s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 599s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 599s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 599s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 599s Index([0, 1, 2, 3], dtype='object', name='foo') 599s a object 599s b int64 599s c uint8 599s d float64 599s e bool 599s f category 599s g datetime64[ns] 599s h datetime64[ns, US/Eastern] 599s dtype: object 599s xexpected 599s bar a b c d e f g h 599s foo 599s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 599s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 599s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 599s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 599s Index([0.0, 1.0, 2.0, 3.0], dtype='Float32', name='foo') 599s bar 599s a object 599s b int64 599s c uint8 599s d float64 599s e bool 599s f category 599s g datetime64[ns] 599s h datetime64[ns, US/Eastern] 599s dtype: object 599s actual 599s Size: 236B 599s Dimensions: (foo: 4) 599s Coordinates: 599s * foo (foo) object 32B 0.0 1.0 2.0 3.0 599s Data variables: 599s a (foo) object 32B 'a' 'b' 'c' 'd' 599s b (foo) int64 32B 1 2 3 4 599s c (foo) uint8 4B 3 4 5 6 599s d (foo) float64 32B 4.0 5.0 6.0 7.0 599s e (foo) bool 4B True False True False 599s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 599s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 599s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 599s a b c d e f g h 599s foo 599s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 599s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 599s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 599s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 599s Index([0.0, 1.0, 2.0, 3.0], dtype='object', name='foo') 599s a object 599s b int64 599s c uint8 599s d float64 599s e bool 599s f category 599s g datetime64[ns] 599s h datetime64[ns, US/Eastern] 599s dtype: object 599s xexpected 599s bar a b c d e f g h 599s foo 599s False a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 599s True b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 599s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 599s True d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 599s Index([False, True, True, True], dtype='boolean', name='foo') 599s bar 599s a object 599s b int64 599s c uint8 599s d float64 599s e bool 599s f category 599s g datetime64[ns] 599s h datetime64[ns, US/Eastern] 599s dtype: object 599s actual 599s Size: 236B 599s Dimensions: (foo: 4) 599s Coordinates: 599s * foo (foo) object 32B False True True True 599s Data variables: 599s a (foo) object 32B 'a' 'b' 'c' 'd' 599s b (foo) int64 32B 1 2 3 4 599s c (foo) uint8 4B 3 4 5 6 599s d (foo) float64 32B 4.0 5.0 6.0 7.0 599s e (foo) bool 4B True False True False 599s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 599s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 599s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 599s a b c d e f g h 599s foo 599s False a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 599s True b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 599s True b 2 4 5.0 False c 2013-01-02 2013-01-02 00:00:00-05:00 599s True b 2 4 5.0 False d 2013-01-02 2013-01-02 00:00:00-05:00 599s True c 3 5 6.0 True b 2013-01-03 2013-01-03 00:00:00-05:00 599s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 599s True c 3 5 6.0 True d 2013-01-03 2013-01-03 00:00:00-05:00 599s True d 4 6 7.0 False b 2013-01-04 2013-01-04 00:00:00-05:00 599s True d 4 6 7.0 False c 2013-01-04 2013-01-04 00:00:00-05:00 599s True d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 599s Index([False, True, True, True, True, True, True, True, True, True], dtype='object', name='foo') 599s a object 599s b int64 599s c uint8 599s d float64 599s e bool 599s f category 599s g datetime64[ns] 599s h datetime64[ns, US/Eastern] 599s dtype: object 599s xexpected 599s bar a b c d e f g h 599s foo 599s pandas_0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 599s pandas_1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 599s pandas_2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 599s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 599s Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='string', name='foo') 599s bar 599s a object 599s b int64 599s c uint8 599s d float64 599s e bool 599s f category 599s g datetime64[ns] 599s h datetime64[ns, US/Eastern] 599s dtype: object 599s actual 599s Size: 236B 599s Dimensions: (foo: 4) 599s Coordinates: 599s * foo (foo) object 32B 'pandas_0' 'pandas_1' 'pandas_2' 'pandas_3' 599s Data variables: 599s a (foo) object 32B 'a' 'b' 'c' 'd' 599s b (foo) int64 32B 1 2 3 4 599s c (foo) uint8 4B 3 4 5 6 599s d (foo) float64 32B 4.0 5.0 6.0 7.0 599s e (foo) bool 4B True False True False 599s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 599s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 599s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 599s a b c d e f g h 599s foo 599s pandas_0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 599s pandas_1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 599s pandas_2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 599s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 599s Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='object', name='foo') 599s a object 599s b int64 599s c uint8 599s d float64 599s e bool 599s f category 599s g datetime64[ns] 599s h datetime64[ns, US/Eastern] 599s dtype: object 599s x................................. 599s 599s =============================== warnings summary =============================== 599s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 599s /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-2tyznvpf' 599s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 599s 599s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 599s /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-7tdam9iu' 599s session.config.cache.set(STEPWISE_CACHE_DIR, []) 599s 599s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 599s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 599s ============================= slowest 30 durations ============================= 599s 0.33s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[string] 599s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[float32] 599s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[interval] 599s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[bool-object] 599s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[datetime-tz] 599s 0.03s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_bool] 599s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[complex64] 599s 0.02s call tests/generic/test_generic.py::TestGeneric::test_truncate_out_of_bounds[DataFrame] 599s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[bool-dtype] 599s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[complex128] 599s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[categorical] 599s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[repeats] 599s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[uint16] 599s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[period] 599s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[datetime] 599s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[timedelta] 599s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_uint] 599s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_float] 599s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[string-python] 599s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[float64] 599s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[range] 599s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[uint8] 599s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[uint32] 599s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_int] 599s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[int8] 599s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[int32] 599s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[uint64] 599s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[int16] 599s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[int64] 599s 0.02s call tests/generic/test_generic.py::TestGeneric::test_truncate_out_of_bounds[Series] 599s ==== 978 passed, 105 skipped, 148 xfailed, 18 xpassed, 2 warnings in 7.45s ===== 599s rdjoqkol test state = true 599s + echo 'rdjoqkol test state = true' 599s + for TEST_SUBSET in $modpath/tests/* 599s + echo /usr/lib/python3/dist-packages/pandas/tests/groupby 599s + grep -q -e __pycache__ 599s + PANDAS_CI=1 599s + LC_ALL=C.UTF-8 599s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/groupby 600s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 600s 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" 600s 600s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 604s ============================= test session starts ============================== 604s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 604s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 604s rootdir: /usr/lib/python3/dist-packages/pandas 604s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 604s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 604s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 604s collected 29434 items / 1832 deselected / 1 skipped / 27602 selected 604s 606s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_aggregate.py ...............................................................................................................................................................................................................................................................................................................................................x..x.......................................................................x....... 607s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_cython.py ........................................................................................................................................................................ 607s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_numba.py sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 607s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_other.py ........................................ 607s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_corrwith.py . 607s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_describe.py ......................... 607s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_groupby_shift_diff.py ............................................... 607s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_is_monotonic.py ...... 607s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_nlargest_nsmallest.py ........................................... 608s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_nth.py .................................................................................................................................................................................................................................... 609s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_quantile.py ..................................................................................................x....x.......................................................................................................................................................................................................................... 613s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_rank.py ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 614s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_sample.py .............. 616s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_size.py .......x....x....x....x....x....x....x....x...............ss 616s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_skew.py . 618s ../../../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...................................... 618s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_all_methods.py ......................................xx..............................................................................................ss..........ss..............ss...... 618s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_api.py ......s..s..............................s..s.......................... 619s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_apply.py .................................................................................................................................... 619s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_apply_mutate.py ..... 619s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_bin_groupby.py ...... 635s ../../../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................................ 635s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_counting.py .................................ssss 635s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_cumulative.py ..................................................... 636s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_filters.py ............................ 645s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_groupby.py ......................................s..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s...................s................................................................................................................... 670s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_groupby_dropna.py ..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................xxxxxxxx.................................................. 670s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_groupby_subclass.py .....s................................................................. 671s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_grouping.py ....................................................................................... 671s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_index_as_string.py .................. 671s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_indexing.py ............................................................................................................................................................................ 672s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_libgroupby.py ........................... 672s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_missing.py ......................... 673s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_numeric_only.py ..................xxx......ssssss..............................xxx.................................................................................................................................................................................................................................................................................................................................................................................. 673s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_pipe.py .. 703s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_raises.py ..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 705s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_reductions.py ...............................................................................................................................................................................................................................................................................................................ss........................................................................................................................................................ 705s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_timegrouper.py ..............................s 705s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/transform/test_numba.py sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 719s ../../../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............................................................................................................................................................................................................ 719s 719s =============================== warnings summary =============================== 719s tests/groupby/test_categorical.py::test_basic 719s /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) 719s return reduction(axis=axis, out=out, **passkwargs) 719s 719s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 719s /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-oa8d01z5' 719s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 719s 719s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 719s /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-63tiv0ec' 719s session.config.cache.set(STEPWISE_CACHE_DIR, []) 719s 719s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 719s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 719s ============================= slowest 30 durations ============================= 719s 0.48s call tests/groupby/test_raises.py::test_groupby_raises_category_on_category[by2-True-cumsum-False-agg] 719s 0.40s call tests/groupby/test_reductions.py::test_ops_general[sem-scipy_sem] 719s 0.28s call tests/groupby/test_groupby.py::test_empty_groupby[False-skew-agg-float-keys1-C] 719s 0.13s teardown tests/groupby/transform/test_transform.py::test_idxmin_idxmax_transform_args[False-False-idxmin] 719s 0.11s call tests/groupby/test_categorical.py::test_basic 719s 0.08s call tests/groupby/test_counting.py::test_count 719s 0.07s call tests/groupby/test_counting.py::TestCounting::test_ngroup_cumcount_pair 719s 0.07s call tests/groupby/test_timegrouper.py::TestGroupBy::test_timegrouper_with_reg_groups 719s 0.06s call tests/groupby/test_categorical.py::test_datetime 719s 0.06s call tests/groupby/test_groupby_subclass.py::test_groupby_preserves_subclass[corrwith-obj0] 719s 0.05s call tests/groupby/test_apply.py::test_apply_concat_preserve_names 719s 0.04s call tests/groupby/methods/test_describe.py::test_frame_describe_multikey 719s 0.04s call tests/groupby/test_groupby.py::test_groupby_multiindex_not_lexsorted 719s 0.04s call tests/groupby/transform/test_transform.py::test_as_index_no_change[corrwith-keys1] 719s 0.03s call tests/groupby/test_apply.py::test_apply_corner_cases 719s 0.03s call tests/groupby/test_categorical.py::test_observed[False] 719s 0.03s call tests/groupby/test_categorical.py::test_describe_categorical_columns 719s 0.03s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-False-False-multi] 719s 0.03s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-False-True-multi] 719s 0.03s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-True-True-True-multi] 719s 0.03s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-True-False-multi] 719s 0.03s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-True-True-multi] 719s 0.03s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-True-False-True-multi] 719s 0.03s call tests/groupby/test_grouping.py::TestGrouping::test_groupby_multiindex_partial_indexing_equivalence 719s 0.03s call tests/groupby/test_groupby.py::test_groupby_selection_other_methods 719s 0.03s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-True-True-False-multi] 719s 0.03s call tests/groupby/test_groupby.py::test_groupby_as_index_agg 719s 0.03s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-True-False-False-multi] 719s 0.02s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-False-False-single] 719s 0.02s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-False-True-range] 719s = 26564 passed, 910 skipped, 1832 deselected, 90 xfailed, 39 xpassed, 3 warnings in 118.70s (0:01:58) = 722s rdjoqkol test state = true 722s + echo 'rdjoqkol test state = true' 722s + for TEST_SUBSET in $modpath/tests/* 722s + echo /usr/lib/python3/dist-packages/pandas/tests/indexes 722s + grep -q -e __pycache__ 722s + PANDAS_CI=1 722s + LC_ALL=C.UTF-8 722s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/indexes 723s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 723s 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" 723s 723s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 730s ============================= test session starts ============================== 730s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 730s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 730s rootdir: /usr/lib/python3/dist-packages/pandas 730s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 730s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 730s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 730s collected 17010 items / 4 deselected / 17006 selected 730s 730s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_constructors.py .......s.. 730s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_formats.py .............. 730s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_indexing.py ............ 730s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_pickle.py . 730s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_reshape.py ..............s.... 730s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_setops.py ............................................................ 730s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_where.py . 730s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_append.py ....... 730s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_astype.py ........... 730s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_category.py ......................................... 730s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_constructors.py ..... 730s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_equals.py ......ss 730s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_fillna.py ... 730s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_formats.py .. 730s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_indexing.py ................................. 730s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_map.py ..................... 730s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_reindex.py ....... 730s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_setops.py .. 731s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_drop_duplicates.py ................................................................................................................ 731s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_equals.py ..................... 731s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_indexing.py ................ 731s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_is_monotonic.py . 731s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_nat.py ...................... 731s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_sort_values.py ................................................................................... 731s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_value_counts.py ............................................ 731s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_asof.py .. 731s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_astype.py ................................. 731s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_delete.py ....................... 731s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_factorize.py .................................................................................... 731s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_fillna.py .. 732s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_insert.py ............................................................................................................................................................................................. 732s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_isocalendar.py .. 732s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_map.py ..... 732s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_normalize.py ......... 732s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_repeat.py .................................................................................................................................................................................................................................................................................................................................................... 733s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_resolution.py .................................................................................................................................................................................... 733s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_round.py ...................................................................................................................................................................................................................... 734s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_shift.py ........................................................................................................................................ 734s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_snap.py ........................ 734s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_to_frame.py .. 734s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_to_julian_date.py ..... 734s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_to_period.py ........................................... 734s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_to_pydatetime.py .. 734s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_to_series.py . 734s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_tz_convert.py .................................... 734s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_tz_localize.py ............................................................................................................................................................ 734s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_unique.py ........................ 735s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_arithmetic.py .....................x 735s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_constructors.py ..................................................................................................................................................................................................................x...x.................................... 737s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_date_range.py .................................................................................................................................................................................................................................................................................................................................................. 737s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_datetime.py .................. 737s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_formats.py ........................................ 737s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_freq_attr.py .......................... 738s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_indexing.py .......................................................................................................................................................................................................................................................................................................................................................................................... 738s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_iter.py ............ 738s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_join.py ...................... 738s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_npfuncs.py . 738s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_ops.py ................ 738s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_partial_slicing.py .................................. 738s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_pickle.py ...... 738s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_reindex.py .. 745s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_scalar_compat.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 746s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_setops.py ................................................................................................................................ 746s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_timezones.py ........................................ 746s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_astype.py ....................................x........................................................................................................................... 747s ../../../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 747s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_equals.py .... 747s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_formats.py ........... 748s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_indexing.py ............................................................................................................................................................................................................................................................................................ 748s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_interval.py .......x....x....x....x.................................................................................................................................................................................................................................. 749s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_interval_range.py ........................................................................................................................................................ 750s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_interval_tree.py .................................................................................................................................................................................................................... 750s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_join.py ... 750s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_pickle.py ... 750s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_setops.py ................................................................................. 750s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_analytics.py ...................................... 750s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_astype.py ... 750s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_compat.py ...... 750s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_constructors.py ..................................................................................s................. 750s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_conversion.py ...... 750s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_copy.py .......... 750s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_drop.py ............. 750s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_duplicates.py .................................................. 750s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_equivalence.py .............. 750s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_formats.py .............. 751s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_get_level_values.py ....... 751s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_get_set.py ................... 751s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_indexing.py ........................................................................................................................................... 751s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_integrity.py ................ 751s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_isin.py .............. 751s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_join.py ....................................................... 751s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_lexsort.py .. 751s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_missing.py ...x.. 752s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_monotonic.py ........... 752s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_names.py ............................... 752s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_partial_indexing.py ..... 752s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_pickle.py . 752s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_reindex.py ............ 752s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_reshape.py ........... 753s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_setops.py ............................................................................................................................................................................................................sss................................................................... 753s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_sorting.py .......................... 753s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_take.py ... 753s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/numeric/test_astype.py ................... 753s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/numeric/test_indexing.py ..............................................................................................................................................ss.......................................... 753s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/numeric/test_join.py ........... 754s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/numeric/test_numeric.py ................................................................................................ 754s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/numeric/test_setops.py .................... 754s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/object/test_astype.py .. 755s ../../../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. 755s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_asfreq.py ............... 755s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_astype.py ............. 755s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_factorize.py .. 755s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_fillna.py . 755s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_insert.py ... 755s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_is_full.py . 755s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_repeat.py ...... 755s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_shift.py ...... 755s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_to_timestamp.py ........ 755s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_constructors.py .................................................................................................. 755s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_formats.py ................... 755s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_freq_attr.py . 756s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_indexing.py ......................................................................... 756s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_join.py ........... 756s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_monotonic.py .. 756s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_partial_slicing.py .............. 756s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_period.py .................................................................................................................................... 756s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_period_range.py ........................... 756s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_pickle.py .... 756s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_resolution.py ......... 756s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_scalar_compat.py ... 756s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_searchsorted.py ........ 756s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_setops.py .............. 756s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_tools.py ............ 756s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/ranges/test_constructors.py ............................. 756s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/ranges/test_indexing.py ............... 756s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/ranges/test_join.py .......... 756s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/ranges/test_range.py ................................................................................. 757s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/ranges/test_setops.py ................................................................... 757s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_any_index.py ......................................................................................................................s......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 760s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_base.py .........................................................................................................................................................................x.............................................................................ssss....ss..........ss......ss.................................................................................................................................ssss...........................................................................................................................................................................................................................................s.......................................................................................................s..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s 761s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_common.py ...........................................................................................................................................................................................................xxxxxxxxxxxxxxxxxxxxxxxxxxxxx.........................................................................................................................sssssssss...s....ss..........................xs.....................sss................................................sss....................................................................................s................s...............................................................................................................................................................................................................................................................................XX........................................... 761s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_datetimelike.py ........................................ 761s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_engines.py ......................................... 761s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_frozen.py .......... 762s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_index_new.py ............................................xxxxssss................................................................................................................ 762s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_indexing.py ......................................................ss...............................s.................................................................................................................................................................................................................................................................................................s........................ 764s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_numpy_compat.py ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ss..................... 765s ../../../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... 770s ../../../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 770s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_subclass.py . 770s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_astype.py ............... 770s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_factorize.py .. 771s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_fillna.py . 771s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_insert.py ............... 771s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_repeat.py . 771s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_shift.py ...... 771s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_arithmetic.py ... 771s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_constructors.py ..................... 771s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_delete.py ... 771s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_formats.py ..... 771s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_freq_attr.py ........... 771s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_indexing.py .................................... 771s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_join.py ....... 771s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_ops.py .......... 771s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_pickle.py . 771s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_scalar_compat.py ........ 771s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_searchsorted.py ........ 771s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_setops.py ................................ 771s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_timedelta.py ... 771s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_timedelta_range.py ............................ 771s 771s =============================== warnings summary =============================== 771s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 771s /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-6qg1cmya' 771s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 771s 771s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 771s /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-1sp73t1o' 771s session.config.cache.set(STEPWISE_CACHE_DIR, []) 771s 771s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 771s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 771s ============================= slowest 30 durations ============================= 771s 0.33s call tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_out[int8] 771s 0.33s call tests/indexes/period/test_indexing.py::TestGetItem::test_getitem_seconds 771s 0.33s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_begin[s] 771s 0.16s call tests/indexes/ranges/test_setops.py::test_range_difference 771s 0.12s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_end[ns] 771s 0.12s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_begin[ns] 771s 0.12s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_end[us] 771s 0.12s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_begin[ms] 771s 0.12s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_begin[us] 771s 0.12s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_end[s] 771s 0.12s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_end[ms] 771s 0.11s call tests/indexes/multi/test_indexing.py::test_pyint_engine 771s 0.11s 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] 771s 0.06s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[both-1] 771s 0.06s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[right-1] 771s 0.06s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[left-1] 771s 0.06s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[neither-1] 771s 0.05s call tests/indexes/multi/test_sorting.py::test_remove_unused_levels_large[datetime64[D]-str] 771s 0.05s call tests/indexes/datetimes/methods/test_tz_localize.py::TestTZLocalize::test_dti_tz_localize_roundtrip[tzlocal()] 771s 0.05s call tests/indexes/period/test_partial_slicing.py::TestPeriodIndex::test_range_slice_seconds[period_range] 771s 0.04s call tests/indexes/datetimes/methods/test_tz_localize.py::TestTZLocalize::test_dti_tz_localize_roundtrip[zoneinfo.ZoneInfo(key='US/Pacific')] 771s 0.04s call tests/indexes/datetimes/test_timezones.py::TestDatetimeIndexTimezones::test_with_tz[tz1] 771s 0.04s call tests/indexes/datetimes/test_timezones.py::TestDatetimeIndexTimezones::test_with_tz[tz0] 771s 0.04s call tests/indexes/multi/test_integrity.py::test_consistency 771s 0.04s call tests/indexes/datetimes/test_constructors.py::TestDatetimeIndex::test_constructor_datetime64_tzformat[W-SUN] 771s 0.04s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[both-10] 771s 0.03s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[right-10] 771s 0.03s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[left-10] 771s 0.03s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[neither-10] 771s 0.03s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonNano::test_date_range_freq_matches_reso 771s = 16700 passed, 254 skipped, 4 deselected, 46 xfailed, 6 xpassed, 2 warnings in 48.56s = 773s + echo 'rdjoqkol test state = true' 773s + for TEST_SUBSET in $modpath/tests/* 773s + echo /usr/lib/python3/dist-packages/pandas/tests/indexing 773s + grep -q -e __pycache__ 773s rdjoqkol test state = true 773s + PANDAS_CI=1 773s + LC_ALL=C.UTF-8 773s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/indexing 774s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 774s 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" 774s 774s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 775s ============================= test session starts ============================== 775s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 775s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 775s rootdir: /usr/lib/python3/dist-packages/pandas 775s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 775s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 775s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 775s collected 4389 items 775s 776s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/interval/test_interval.py .............................. 776s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/interval/test_interval_new.py ..................... 776s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_chaining_and_caching.py .. 776s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_datetime.py .. 776s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_getitem.py ............................................................................. 776s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_iloc.py ................ 777s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_indexing_slow.py .......... 778s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_loc.py ................................................................................................................................. 778s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_multiindex.py ................ 778s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_partial.py ............. 778s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_setitem.py ........................... 778s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_slice.py ............................. 778s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_sorted.py ......... 778s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_at.py ......................................... 779s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_categorical.py .................s................................................................................................ 779s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_chaining_and_caching.py .............................. 779s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_check_indexer.py ....................s.... 781s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_coercion.py ..........xxxxxxx...............................................................xx............................................xxxx....x............................................................xxxxx..................xx............................................................................................................................................................................................................x 781s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_datetime.py .........ss 781s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_floats.py ............................................................................................................................................... 781s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_iat.py ..... 782s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_iloc.py .................................................................................................................................................................................................................. 782s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_indexers.py ...... 785s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_indexing.py ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 788s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_loc.py .............................................................................................................................x...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s...................................................................................................................................................................................................................................................................................................................................................................s.................................... 789s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_na_indexing.py .............................................................................................................................................................................................................................................................................. 789s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_partial.py .................................... 789s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_scalar.py ...................................... 789s 789s =============================== warnings summary =============================== 789s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 789s /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-iibw9jrv' 789s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 789s 789s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 789s /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-67puefe3' 789s session.config.cache.set(STEPWISE_CACHE_DIR, []) 789s 789s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 789s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 789s ============================= slowest 30 durations ============================= 789s 0.39s call tests/indexing/test_loc.py::TestLocBaseIndependent::test_loc_non_unique_memory_error[900000-100000] 789s 0.22s call tests/indexing/test_loc.py::TestLocBaseIndependent::test_loc_getitem_range_from_spmatrix[int64-coo_matrix] 789s 0.14s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[a-0] 789s 0.13s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[a-3] 789s 0.13s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[a-1] 789s 0.13s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[a-4] 789s 0.13s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[a-2] 789s 0.12s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[b-3] 789s 0.12s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[b-1] 789s 0.12s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[b-4] 789s 0.12s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[b-2] 789s 0.11s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[b-0] 789s 0.09s call tests/indexing/test_chaining_and_caching.py::TestChaining::test_detect_chained_assignment_implicit_take2 789s 0.09s call tests/indexing/test_chaining_and_caching.py::TestChaining::test_detect_chained_assignment_str 789s 0.08s call tests/indexing/test_chaining_and_caching.py::TestChaining::test_detect_chained_assignment_setting_entire_column 789s 0.08s call tests/indexing/test_chaining_and_caching.py::TestChaining::test_detect_chained_assignment_implicit_take 789s 0.05s call tests/indexing/multiindex/test_setitem.py::TestMultiIndexSetItem::test_groupby_example 789s 0.04s call tests/indexing/multiindex/test_slice.py::TestMultiIndexSlicers::test_per_axis_per_level_setitem 789s 0.03s call tests/indexing/test_loc.py::TestLocSeries::test_loc_nonunique_masked_index 789s 0.03s call tests/indexing/multiindex/test_slice.py::TestMultiIndexSlicers::test_per_axis_per_level_getitem 789s 0.02s teardown tests/indexing/test_scalar.py::TestMultiIndexScalar::test_multiindex_at_get_one_level 789s 0.02s call tests/indexing/multiindex/test_setitem.py::TestMultiIndexSetItem::test_setitem_multiindex3 789s 0.02s call tests/indexing/multiindex/test_slice.py::TestMultiIndexSlicers::test_per_axis_per_level_doc_examples 789s 0.01s call tests/indexing/multiindex/test_slice.py::TestMultiIndexSlicers::test_loc_axis_arguments 789s 0.01s call tests/indexing/test_loc.py::TestLocCallable::test_frame_loc_setitem_callable 789s 0.01s call tests/indexing/test_chaining_and_caching.py::TestChaining::test_detect_chained_assignment_false_positives 789s 0.01s call tests/indexing/multiindex/test_slice.py::TestMultiIndexSlicers::test_multiindex_slicers_non_unique 789s 0.01s call tests/indexing/test_indexing.py::TestMisc::test_rhs_alignment 789s 0.01s call tests/indexing/test_categorical.py::TestCategoricalIndex::test_ix_categorical_index_non_unique[False] 789s 0.01s call tests/indexing/test_indexing.py::TestDatetimelikeCoercion::test_setitem_dt64_string_values[tzlocal()-loc-key2-Index] 789s =========== 4360 passed, 6 skipped, 23 xfailed, 2 warnings in 15.03s =========== 790s + echo 'rdjoqkol test state = true' 790s + for TEST_SUBSET in $modpath/tests/* 790s + echo /usr/lib/python3/dist-packages/pandas/tests/interchange 790s + grep -q -e __pycache__ 790s rdjoqkol test state = true 790s + PANDAS_CI=1 790s + LC_ALL=C.UTF-8 790s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/interchange 791s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 791s 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" 791s 791s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 791s ============================= test session starts ============================== 791s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 791s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 791s rootdir: /usr/lib/python3/dist-packages/pandas 791s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 791s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 791s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 791s collected 140 items 791s 791s ../../../usr/lib/python3/dist-packages/pandas/tests/interchange/test_impl.py ..sssssssss..............sssss........s..s..ssssssssssssssssssssssssssssssss. 791s ../../../usr/lib/python3/dist-packages/pandas/tests/interchange/test_spec_conformance.py ................ 791s ../../../usr/lib/python3/dist-packages/pandas/tests/interchange/test_utils.py ................sssssssssssssssssssssssssssssss 791s 791s =============================== warnings summary =============================== 791s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 791s /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-n0q11ccz' 791s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 791s 791s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 791s /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-f94tair1' 791s session.config.cache.set(STEPWISE_CACHE_DIR, []) 791s 791s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 791s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 791s ============================= slowest 30 durations ============================= 791s 0.02s call tests/interchange/test_impl.py::test_dataframe[4] 791s 0.01s call tests/interchange/test_impl.py::test_dataframe[3] 791s 0.01s call tests/interchange/test_impl.py::test_dataframe[0] 791s 0.01s call tests/interchange/test_impl.py::test_dataframe[1] 791s 0.01s call tests/interchange/test_impl.py::test_dataframe[2] 791s 0.01s call tests/interchange/test_impl.py::test_categorical_dtype[data0] 791s 791s (24 durations < 0.005s hidden. Use -vv to show these durations.) 791s ================== 61 passed, 79 skipped, 2 warnings in 0.46s ================== 791s rdjoqkol test state = true 791s + echo 'rdjoqkol test state = true' 791s + for TEST_SUBSET in $modpath/tests/* 791s + echo /usr/lib/python3/dist-packages/pandas/tests/internals 791s + grep -q -e __pycache__ 791s + PANDAS_CI=1 791s + LC_ALL=C.UTF-8 791s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/internals 792s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 792s 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" 792s 792s 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.k7pV9B/build.APd/src/pyproject.toml 792s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 792s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 792s collected 257 items 792s 792s ../../../usr/lib/python3/dist-packages/pandas/tests/internals/test_api.py ......... 793s ../../../usr/lib/python3/dist-packages/pandas/tests/internals/test_internals.py .................................................................................................................................................................................................................................................... 794s ../../../usr/lib/python3/dist-packages/pandas/tests/internals/test_managers.py .... 794s 794s =============================== warnings summary =============================== 794s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 794s /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-5sppom3s' 794s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 794s 794s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 794s /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-31e53k8p' 794s session.config.cache.set(STEPWISE_CACHE_DIR, []) 794s 794s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 794s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 794s ============================= slowest 30 durations ============================= 794s 0.49s call tests/internals/test_managers.py::test_array_manager_depr_env_var[block] 794s 0.46s call tests/internals/test_managers.py::test_array_manager_depr_env_var[array] 794s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_equals_block_order_different_dtypes[c:sparse;d:sparse_na;b:f8] 794s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[4-int64] 794s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[4-float64] 794s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[4-uint64] 794s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[3-int64] 794s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[3-uint64] 794s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[3-float64] 794s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[5-int64] 794s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[5-uint64] 794s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[5-float64] 794s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[1-int64] 794s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: category2-object] 794s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: category-i8] 794s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[1-uint64] 794s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: M8[ns]; b: bool-object] 794s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: M8[ns]; b: m8[ns]-object] 794s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_equals_block_order_different_dtypes[a:i8;e:dt;f:td;g:string] 794s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: category; b: category2-object] 794s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[1-float64] 794s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: m8[ns]; b: i8-object] 794s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: category; b: category-i8] 794s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: M8[ns]; b: category-object] 794s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: bool; b: i8-object] 794s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: f8-f8] 794s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: complex-complex] 794s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: f4; b: i8-f8] 794s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[0-int64] 794s 0.01s call tests/internals/test_internals.py::TestBlockManager::test_interleave_dtype[a: f4; b: i8; d: object-object] 794s ======================= 257 passed, 2 warnings in 1.96s ======================== 794s rdjoqkol test state = true 794s + echo 'rdjoqkol test state = true' 794s + for TEST_SUBSET in $modpath/tests/* 794s + echo /usr/lib/python3/dist-packages/pandas/tests/io 794s + grep -q -e __pycache__ 794s + PANDAS_CI=1 794s + LC_ALL=C.UTF-8 794s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/io 795s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 795s 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" 795s 795s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 804s ============================= test session starts ============================== 804s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 804s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 804s rootdir: /usr/lib/python3/dist-packages/pandas 804s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 804s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 804s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 804s collected 15519 items / 201 deselected / 2 skipped / 15318 selected 804s 804s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_odf.py ..... 804s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_odswriter.py .......... 804s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_openpyxl.py ...................................................... 819s ../../../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 821s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_style.py ...................................................................................................................................s 835s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_writers.py .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 835s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_xlrd.py ....... 835s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_xlsxwriter.py ..... 835s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_bar.py ..........................................................................................................................s 835s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_exceptions.py ... 836s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_format.py ......................................................................................................... 836s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_highlight.py ................................................................................................ 837s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_html.py ........................................................................................... 837s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_matplotlib.py ........................................................... 837s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_non_unique.py ......... 838s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_style.py ................................................................................................................................................................................................. 838s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_to_latex.py ............................................................................................................................................................ 838s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_to_string.py ..... 839s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_tooltip.py .... 839s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_console.py ........... 839s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_css.py ............................................................................................... 839s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_eng_formatting.py ....... 840s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_format.py .................................................................................................................................................................................. 840s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_ipython_compat.py ss..s 840s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_printing.py ......... 840s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_csv.py ..........s.................................................................................. 841s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_excel.py .......................................................................................................................................................................................................................................................................................................................................................................................................................... 842s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_html.py .....................................................................................................................................................................................................................................................................................................................................................................s................... 842s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_latex.py ............................................................................................ 842s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_markdown.py .......... 843s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_string.py ...............................................s........................................... 843s ../../../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....... 843s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_deprecated_kwargs.py . 844s ../../../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........................... 844s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_json_table_schema_ext_dtype.py ..................... 844s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_normalize.py ..................................................... 849s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_pandas.py ...........................................................................................................xxxx................................xxx........................................................................................................................................................................s........xxxxxxxxxxxxxxxxxx................................................................xx.............s.....x........ssssssssssssssssssssssssssssssss...sssss.s. 849s ../../../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........... 849s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_ujson.py ................................................................................................................................................................................................................... 850s ../../../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 851s ../../../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 851s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_data_list.py ...s...s...s...s 851s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_decimal.py ......ss...s 853s ../../../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 853s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_float.py ...s.......s.....................sss....x.....x...ss 853s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_index.py ......ss......ss...s............ssss...s...s...s...s...s...s...s 853s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_inf.py ......ss......ss...s 853s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_ints.py ...s............ssss...s......ss...s.........sss.........sss......ss......ss...s 853s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_iterator.py ...s...s...s.........sss...s 853s ../../../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 853s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_verbose.py ...s...s 854s ../../../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 857s ../../../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 857s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/dtypes/test_empty.py ...s...s...s...s...s...s...s...s........................ssssssss 857s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_c_parser_only.py .......................................................................... 858s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_comment.py ......ss.........sss...s...s...s..................ssssss......ssxx.s 860s ../../../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 860s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_concatenate_chunks.py ss 860s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_converters.py ...s............ssss...s...s...s......ss...s...s 860s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_dialect.py ...s...s...s......................................................ssssssssssssssssss..................ssssss 861s ../../../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 862s ../../../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 862s ../../../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 862s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_mangle_dupes.py ...s...s...s.........sss.........sss...s...s...s......ss 863s ../../../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 867s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py ................ssss.....ssssssssssssssssss 869s ../../../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 869s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_python_parser_only.py ..................................................................................... 869s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_quoting.py .........sss......ss...s..................ssssss............ssss...............sssss......ss......ss......ss 870s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_read_fwf.py ..........................................................................sss.. 870s ../../../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 870s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_textreader.py ..................................... 870s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_unsupported.py ..........s...s..xs...s 870s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_upcast.py ...........................ssss 870s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/usecols/test_parse_dates.py ......ss...s...s...s............ssss 870s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/usecols/test_strings.py ...s...s......ss......ss 871s ../../../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 872s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py ....x................ 873s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_categorical.py ..... 873s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_compat.py .... 874s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_complex.py ......... 874s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_errors.py ................ 878s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py ...................................................xxxxxxxxx................................................................................................................................... 878s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_keys.py .... 879s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_put.py ...................... 879s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_pytables_missing.py s 879s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_read.py ....................s 879s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_retain_attributes.py ..... 880s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_round_trip.py ..............................s 884s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_select.py ...x.....x............... 887s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py ............................................x..................... 887s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_subclass.py .. 887s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_time_series.py .... 888s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_timezones.py .......................................................................... 890s ../../../usr/lib/python3/dist-packages/pandas/tests/io/sas/test_byteswap.py .......... 890s ../../../usr/lib/python3/dist-packages/pandas/tests/io/sas/test_sas.py ... 890s ../../../usr/lib/python3/dist-packages/pandas/tests/io/sas/test_sas7bdat.py ....................... 890s ../../../usr/lib/python3/dist-packages/pandas/tests/io/sas/test_xport.py ....... 891s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_clipboard.py .......QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-ubuntu' 892s ...............................................................................................................................................................................................................................................................................................................................ssssss.. 892s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_common.py .......................................................s....s........ss.......s.........s.......s......................................... 894s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_compression.py ........................................................................................................................................ 894s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_fsspec.py .........ssssssssss..........s 894s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_gbq.py .. 894s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_gcs.py ssssssssssssssssss. 903s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_html.py .........ssssss...............................................................................................................................s.................... 909s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py ...ss.......ss.......ss....ss 909s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_parquet.py .ssss.ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.ssssssss 916s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_pickle.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 916s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_s3.py sss 916s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_spss.py .......s.. 935s ../../../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................ 941s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_stata.py ..............................................................................................................................................................................................................................................................................................................................................................................s.................................................................................................................................................................................................................................................... 942s ../../../usr/lib/python3/dist-packages/pandas/tests/io/xml/test_to_xml.py ........................................................................s...............................................................ss 946s ../../../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. 946s ../../../usr/lib/python3/dist-packages/pandas/tests/io/xml/test_xml_dtypes.py .............................................. 946s 946s =============================== warnings summary =============================== 946s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 946s /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-ungvilar' 946s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 946s 946s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 946s /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-hnckegm0' 946s session.config.cache.set(STEPWISE_CACHE_DIR, []) 946s 946s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 946s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 946s ============================= slowest 30 durations ============================= 946s 1.02s call tests/io/test_pickle.py::test_pickle_big_dataframe_compression[gzip-5] 946s 1.02s call tests/io/pytables/test_store.py::test_no_track_times 946s 1.00s call tests/io/test_pickle.py::test_pickle_big_dataframe_compression[gzip-4] 946s 0.90s call tests/io/test_html.py::TestReadHtml::test_banklist_url[bs4] 946s 0.70s call tests/io/pytables/test_select.py::test_select_iterator_complete_8014 946s 0.60s call tests/io/test_compression.py::test_with_missing_lzma_runtime 946s 0.53s call tests/io/test_pickle.py::test_round_trip_current[mi-expected30-to_pickle-pandas_proto_4] 946s 0.51s call tests/io/pytables/test_categorical.py::test_categorical 946s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[storage_options2-gz_csv_responder-read_csv] 946s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[None-gz_csv_responder-read_csv] 946s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[None-stata_responder-read_stata] 946s 0.50s teardown tests/io/json/test_pandas.py::TestPandasContainer::test_url[created_at-dtype0] 946s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[None-gz_json_responder-read_json] 946s 0.50s teardown tests/io/xml/test_xml.py::test_wrong_url[lxml] 946s 0.50s teardown tests/io/xml/test_xml.py::test_url 946s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[storage_options1-gz_csv_responder-read_csv] 946s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[storage_options2-gz_json_responder-read_json] 946s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[zip-c-infer] 946s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[bz2-c-explicit] 946s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[None-csv_responder-read_csv] 946s 0.50s teardown tests/io/parser/common/test_file_buffer_url.py::test_url[python] 946s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[None-json_responder-read_json] 946s 0.50s teardown tests/io/test_http_headers.py::test_request_headers[storage_options2-csv_responder-read_csv] 946s 0.50s teardown tests/io/test_html.py::TestReadHtml::test_python_docs_table[bs4] 946s 0.50s teardown tests/io/test_html.py::TestReadHtml::test_multiple_matches[bs4] 946s 0.50s teardown tests/io/xml/test_xml.py::test_url_path_error[etree] 946s 0.50s teardown tests/io/xml/test_xml.py::test_url_path_error[lxml] 946s 0.50s teardown tests/io/test_html.py::TestReadHtml::test_bad_url_protocol[lxml] 946s 0.50s teardown tests/io/test_html.py::TestReadHtml::test_bad_url_protocol[bs4] 946s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[zstd-c-explicit] 946s = 12148 passed, 3017 skipped, 201 deselected, 155 xfailed, 2 warnings in 151.08s (0:02:31) = 948s rdjoqkol test state = true 948s + echo 'rdjoqkol test state = true' 948s + for TEST_SUBSET in $modpath/tests/* 948s + echo /usr/lib/python3/dist-packages/pandas/tests/libs 948s + grep -q -e __pycache__ 948s + PANDAS_CI=1 948s + LC_ALL=C.UTF-8 948s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/libs 949s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 949s 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" 949s 949s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 950s ============================= test session starts ============================== 950s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 950s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 950s rootdir: /usr/lib/python3/dist-packages/pandas 950s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 950s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 950s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 950s collected 2279 items 950s 952s ../../../usr/lib/python3/dist-packages/pandas/tests/libs/test_hashtable.py ..............s.....................................................................s.............s.......................................................s.............s.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s................................................................................................................................................................................................. 952s ../../../usr/lib/python3/dist-packages/pandas/tests/libs/test_join.py ................. 952s ../../../usr/lib/python3/dist-packages/pandas/tests/libs/test_lib.py .................................................................................. 952s ../../../usr/lib/python3/dist-packages/pandas/tests/libs/test_libalgos.py ........ 952s 952s =============================== warnings summary =============================== 952s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 952s /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-fgtu0jxq' 952s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 952s 952s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 952s /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-37mzeknt' 952s session.config.cache.set(STEPWISE_CACHE_DIR, []) 952s 952s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 952s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 952s ============================= slowest 30 durations ============================= 952s 0.01s teardown tests/libs/test_libalgos.py::TestInfinity::test_infinity_against_nan 952s 0.01s setup tests/libs/test_lib.py::TestIndexing::test_maybe_indices_to_slice_left_edge_not_slice_end_steps[1-2] 952s 0.01s setup tests/libs/test_hashtable.py::TestHashTable::test_no_reallocation[82-Float32HashTable-float32] 952s 0.01s call tests/libs/test_hashtable.py::test_unique_label_indices 952s 0.01s call tests/libs/test_libalgos.py::TestInfinity::test_infinity_sort 952s 952s (25 durations < 0.005s hidden. Use -vv to show these durations.) 952s ================= 2273 passed, 6 skipped, 2 warnings in 2.96s ================== 953s rdjoqkol test state = true 953s + echo 'rdjoqkol test state = true' 953s + for TEST_SUBSET in $modpath/tests/* 953s + echo /usr/lib/python3/dist-packages/pandas/tests/plotting 953s + grep -q -e __pycache__ 953s + PANDAS_CI=1 953s + LC_ALL=C.UTF-8 953s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/plotting 953s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 953s 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" 953s 953s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 955s ============================= test session starts ============================== 955s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 955s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 955s rootdir: /usr/lib/python3/dist-packages/pandas 955s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 955s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 955s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 955s collected 1423 items / 212 deselected / 1211 selected 955s 973s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame.py ..................................................XX.........................s.s.s.s....................................................................................................x...................................................................................... 977s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame_color.py ......................................................................................... 978s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame_groupby.py ...... 979s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame_legend.py x..................... 985s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame_subplots.py .........x....................XX................................................................... 986s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_hist_box_by.py ............................. 986s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_backend.py .....s. 989s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_boxplot_method.py .................................................... 990s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_common.py ... 991s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_converter.py ............................................ 1005s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_datetimelike.py ...............................................................................................................x..........................................x.......................x...............x..... 1005s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_groupby.py ................. 1010s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_hist_method.py ...........................x..x...................................................... 1017s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_misc.py s....................sss...................sss...................sss.................................. 1022s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_series.py ...............................XXXX.............................x........................................................x......................... 1022s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_style.py ...................................... 1022s 1022s =============================== warnings summary =============================== 1022s tests/plotting/frame/test_frame.py: 11 warnings 1022s /usr/lib/python3/dist-packages/matplotlib/transforms.py:2650: RuntimeWarning: divide by zero encountered in scalar divide 1022s x_scale = 1.0 / inw 1022s 1022s tests/plotting/frame/test_frame.py: 11 warnings 1022s /usr/lib/python3/dist-packages/matplotlib/transforms.py:2652: RuntimeWarning: invalid value encountered in scalar multiply 1022s self._mtx = np.array([[x_scale, 0.0, -inl*x_scale], 1022s 1022s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1022s /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-l5s_kubn' 1022s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1022s 1022s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1022s /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-nyj9uiie' 1022s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1022s 1022s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1022s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 1022s ============================= slowest 30 durations ============================= 1022s 0.82s call tests/plotting/test_misc.py::TestDataFramePlots::test_scatter_matrix_axis_smaller[True] 1022s 0.70s call tests/plotting/test_converter.py::test_registry_mpl_resets 1022s 0.65s call tests/plotting/test_datetimelike.py::TestTSPlot::test_finder_daily 1022s 0.63s call tests/plotting/test_converter.py::TestRegistration::test_dont_register_by_default 1022s 0.62s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_errorbar_timeseries[bar] 1022s 0.56s call tests/plotting/test_misc.py::TestSeriesPlots::test_bootstrap_plot 1022s 0.50s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_sharex_and_ax 1022s 0.49s call tests/plotting/test_misc.py::TestDataFramePlots::test_scatter_matrix_axis[True] 1022s 0.47s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_errorbar_timeseries[barh] 1022s 0.44s call tests/plotting/frame/test_frame_subplots.py::TestDataFramePlotsSubplots::test_subplots_ts_share_axes 1022s 0.39s call tests/plotting/test_misc.py::TestDataFramePlots::test_scatter_matrix_axis[False] 1022s 0.39s call tests/plotting/test_misc.py::TestDataFramePlots::test_scatter_matrix_axis_smaller[False] 1022s 0.39s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_kde_df 1022s 0.38s call tests/plotting/test_boxplot_method.py::TestDataFrameGroupByPlots::test_boxplot_legacy3[False-None-1-layout1] 1022s 0.37s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_errorbar_timeseries[line] 1022s 0.35s call tests/plotting/test_datetimelike.py::TestTSPlot::test_frame_inferred 1022s 0.33s call tests/plotting/test_datetimelike.py::TestTSPlot::test_line_plot_period_mlt_series[4D] 1022s 0.33s call tests/plotting/test_hist_method.py::TestDataFrameGroupByPlots::test_histtype_argument[barstacked-True] 1022s 0.33s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_sharey_and_ax 1022s 0.31s call tests/plotting/test_boxplot_method.py::TestDataFrameGroupByPlots::test_boxplot_legacy3[True-UserWarning-3-layout0] 1022s 0.31s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_hist_df 1022s 0.30s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_df_gridspec_patterns_vert_horiz 1022s 0.26s call tests/plotting/frame/test_frame_subplots.py::TestDataFramePlotsSubplots::test_subplots_constrained_layout 1022s 0.25s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_hist_df_coord[data0] 1022s 0.25s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_hist_df_coord[data1] 1022s 0.25s call tests/plotting/test_boxplot_method.py::TestDataFramePlots::test_stacked_boxplot_set_axis 1022s 0.24s call tests/plotting/test_misc.py::test_savefig[index1-data0-hexbin] 1022s 0.24s call tests/plotting/test_datetimelike.py::TestTSPlot::test_line_plot_datetime_frame[D] 1022s 0.24s call tests/plotting/test_misc.py::test_savefig[index0-data0-hexbin] 1022s 0.24s call tests/plotting/test_misc.py::test_savefig[index2-data0-hexbin] 1022s = 1177 passed, 15 skipped, 212 deselected, 11 xfailed, 8 xpassed, 24 warnings in 68.43s (0:01:08) = 1022s + echo 'rdjoqkol test state = true' 1022s rdjoqkol test state = true 1022s + for TEST_SUBSET in $modpath/tests/* 1022s + echo /usr/lib/python3/dist-packages/pandas/tests/reductions 1022s + grep -q -e __pycache__ 1022s + PANDAS_CI=1 1022s + LC_ALL=C.UTF-8 1022s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/reductions 1023s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1023s 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" 1023s 1023s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1024s ============================= test session starts ============================== 1024s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1024s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1024s rootdir: /usr/lib/python3/dist-packages/pandas 1024s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 1024s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 1024s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1024s collected 550 items 1024s 1025s ../../../usr/lib/python3/dist-packages/pandas/tests/reductions/test_reductions.py .....................................................................................................................................................................................................................................................................................................................................s....................................................................................................................................... 1025s ../../../usr/lib/python3/dist-packages/pandas/tests/reductions/test_stat_reductions.py ......................................................................................... 1025s 1025s =============================== warnings summary =============================== 1025s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1025s /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-7ofiec26' 1025s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1025s 1025s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1025s /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-aflr51a1' 1025s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1025s 1025s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1025s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 1025s ============================= slowest 30 durations ============================= 1025s 0.36s call tests/reductions/test_stat_reductions.py::TestSeriesStatReductions::test_skew 1025s 0.05s call tests/reductions/test_reductions.py::TestIndexReductions::test_minmax_tz['Asia/Tokyo'] 1025s 0.02s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_int[int32-True] 1025s 0.02s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_float[float64-True] 1025s 0.02s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_float[float64-False] 1025s 0.02s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_int[int64-True] 1025s 0.02s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_int[int32-False] 1025s 0.02s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_int[int64-False] 1025s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_float[float32-False] 1025s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_float[float32-True] 1025s 0.01s call tests/reductions/test_reductions.py::TestIndexReductions::test_timedelta_ops 1025s 0.01s call tests/reductions/test_reductions.py::TestReductions::test_argminmax 1025s 1025s (18 durations < 0.005s hidden. Use -vv to show these durations.) 1025s ================== 549 passed, 1 skipped, 2 warnings in 1.88s ================== 1026s rdjoqkol test state = true 1026s + echo 'rdjoqkol test state = true' 1026s + for TEST_SUBSET in $modpath/tests/* 1026s + echo /usr/lib/python3/dist-packages/pandas/tests/resample 1026s + grep -q -e __pycache__ 1026s + PANDAS_CI=1 1026s + LC_ALL=C.UTF-8 1026s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/resample 1026s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1026s 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" 1026s 1026s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1027s ============================= test session starts ============================== 1027s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1027s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1027s rootdir: /usr/lib/python3/dist-packages/pandas 1027s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 1027s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 1027s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1027s collected 4179 items 1027s 1031s ../../../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............................................................................................................................................................................................................................................................................................................................................................................................................................................................. 1049s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_datetime_index.py ................................................................................ssss............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x...x...x...x..........................................................................................................................................................................................................................................................................................................................................................................ss 1053s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_period_index.py .................................................................................................................................................................................................................................................................................................................................................................................................................................x.................................................................................. 1054s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_resample_api.py ..................................................................................................................................................................................................... 1055s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_resampler_grouper.py s................................................... 1056s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_time_grouper.py .........................x...................... 1056s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_timedelta.py .......................s 1056s 1056s =============================== warnings summary =============================== 1056s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1056s /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-m4a82y75' 1056s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1056s 1056s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1056s /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-zc8o6sr8' 1056s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1056s 1056s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1056s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 1056s ============================= slowest 30 durations ============================= 1056s 0.18s call tests/resample/test_datetime_index.py::test_resample_dtype_coercion[s] 1056s 0.13s call tests/resample/test_period_index.py::TestPeriodIndex::test_annual_upsample_cases[D-D-start-bfill-NOV] 1056s 0.12s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-43200-s-0.5-D-1] 1056s 0.12s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-43200-s-0.5-D-2] 1056s 0.12s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-43200-s-0.5-D-3] 1056s 0.12s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-86400-s-1-D-3] 1056s 0.11s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-30-s-0.5-Min-1] 1056s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-30-s-0.5-Min-1] 1056s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-60-s-1-Min-1] 1056s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-30-s-0.5-Min-2] 1056s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-60-s-1-Min-1] 1056s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-60-s-1-Min-2] 1056s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-30-s-0.5-Min-3] 1056s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-30-s-0.5-Min-1] 1056s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-3600-s-1-h-3] 1056s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-60-s-1-Min-3] 1056s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-3600-s-1-h-2] 1056s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-30-s-0.5-Min-3] 1056s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-60-s-1-Min-1] 1056s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-3600-s-1-h-1] 1056s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-21600-s-0.25-D-2] 1056s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-3600-s-1-h-2] 1056s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-21600-s-0.25-D-3] 1056s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-60-s-1-Min-2] 1056s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-60-s-1-Min-2] 1056s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-30-s-0.5-Min-2] 1056s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-60-s-1-Min-3] 1056s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-30-s-0.5-Min-3] 1056s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-21600-s-0.25-D-1] 1056s 0.10s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-86400-s-1-D-1] 1056s =========== 4117 passed, 8 skipped, 54 xfailed, 2 warnings in 29.31s =========== 1056s rdjoqkol test state = true 1056s + echo 'rdjoqkol test state = true' 1056s + for TEST_SUBSET in $modpath/tests/* 1056s + echo /usr/lib/python3/dist-packages/pandas/tests/reshape 1056s + grep -q -e __pycache__ 1056s + PANDAS_CI=1 1056s + LC_ALL=C.UTF-8 1056s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/reshape 1057s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1057s 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" 1057s 1057s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1059s ============================= test session starts ============================== 1059s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1059s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1059s rootdir: /usr/lib/python3/dist-packages/pandas 1059s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 1059s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 1059s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1059s collected 2610 items / 1 deselected / 2609 selected 1059s 1059s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_append.py .................................................................................. 1059s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_append_common.py ...........................sssssssss....................................................... 1059s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_categorical.py ............. 1060s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_concat.py .............................................................................................. 1060s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_dataframe.py ..................... 1060s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_datetimes.py ..................................................................................................x......... 1060s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_empty.py .....................s.....s.....s.....s.....s.......... 1060s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_index.py ............................................................. 1060s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_invalid.py ....... 1060s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_series.py ............. 1060s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_sort.py .......... 1061s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_join.py .......s..........................s....................................... 1065s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge.py ..............................................................................................................................................................................................................................................................................................................................................................................................................................ssssssss..............................................................................................................................................................................................................................ss..........................................................................................................................................................................................................................................................................ssss........ 1066s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge_asof.py .s...................................................................................................s.....................s....s.s.s.s.............sss.. 1066s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge_cross.py ................. 1066s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge_index_as_string.py ................................................................................ 1066s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge_ordered.py ..................... 1067s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_multi.py .....s.s.................................. 1068s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_crosstab.py ..................................... 1068s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_cut.py ..................................................................................................................................... 1068s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_from_dummies.py ......................................... 1069s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_get_dummies.py ...................................................................................................................................................ss 1070s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_melt.py ..........................................................s 1072s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_pivot.py ...........................................................................xx................................................................................................. 1072s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_pivot_multilevel.py .......... 1073s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_qcut.py ................................................................................ 1073s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_union_categoricals.py .......................................... 1073s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_util.py ................. 1073s 1073s =============================== warnings summary =============================== 1073s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1073s /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-4okt5h0q' 1073s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1073s 1073s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1073s /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-jousnieh' 1073s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1073s 1073s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1073s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 1073s ============================= slowest 30 durations ============================= 1073s 0.09s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_multi_functions 1073s 0.08s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_normalize 1073s 0.07s call tests/reshape/merge/test_join.py::TestJoin::test_full_outer_join 1073s 0.06s call tests/reshape/test_pivot.py::TestPivotTable::test_margins 1073s 0.06s call tests/reshape/merge/test_merge.py::TestMerge::test_merge_non_unique_indexes 1073s 0.06s call tests/reshape/test_crosstab.py::TestCrosstab::test_margin_normalize 1073s 0.05s call tests/reshape/test_crosstab.py::TestCrosstab::test_margin_dropna6 1073s 0.05s call tests/reshape/concat/test_concat.py::TestConcatenate::test_concat_order 1073s 0.05s call tests/reshape/merge/test_join.py::TestJoin::test_right_outer_join 1073s 0.04s call tests/reshape/test_crosstab.py::test_categoricals[category-category] 1073s 0.04s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_timegrouper 1073s 0.04s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_normalize_arrays 1073s 0.04s call tests/reshape/test_crosstab.py::test_categoricals[category-int64] 1073s 0.04s call tests/reshape/merge/test_multi.py::TestMergeMulti::test_compress_group_combinations 1073s 0.03s call tests/reshape/test_crosstab.py::test_categoricals[int64-category] 1073s 0.03s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_margins_set_margin_name 1073s 0.03s call tests/reshape/test_crosstab.py::test_categoricals[int64-int64] 1073s 0.03s call tests/reshape/test_qcut.py::test_qcut_binning_issues 1073s 0.03s call tests/reshape/merge/test_join.py::TestJoin::test_join_many_non_unique_index 1073s 0.03s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_ndarray[tuple] 1073s 0.03s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_ndarray[list] 1073s 0.03s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_timegrouper_double 1073s 0.03s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_ndarray[array] 1073s 0.03s call tests/reshape/test_pivot.py::TestPivotTable::test_daily 1073s 0.03s call tests/reshape/merge/test_merge.py::TestMerge::test_validation 1073s 0.03s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_duplicate_names 1073s 0.02s call tests/reshape/merge/test_merge.py::TestMerge::test_merge_indicator_result_integrity 1073s 0.02s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_table_margins_name_with_aggfunc_list 1073s 0.02s call tests/reshape/merge/test_multi.py::TestMergeMulti::test_left_join_multi_index[True-False] 1073s 0.02s call tests/reshape/merge/test_merge.py::TestMerge::test_indicator 1073s ==== 2561 passed, 45 skipped, 1 deselected, 3 xfailed, 2 warnings in 15.52s ==== 1073s + echo 'rdjoqkol test state = true' 1073s + for TEST_SUBSET in $modpath/tests/* 1073s rdjoqkol test state = true 1073s + echo /usr/lib/python3/dist-packages/pandas/tests/scalar 1073s + grep -q -e __pycache__ 1073s + PANDAS_CI=1 1073s + LC_ALL=C.UTF-8 1073s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/scalar 1074s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1074s 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" 1074s 1074s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1077s ============================= test session starts ============================== 1077s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1077s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1077s rootdir: /usr/lib/python3/dist-packages/pandas 1077s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 1077s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 1077s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1077s collected 4353 items 1077s 1077s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_arithmetic.py ............................................ 1077s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_constructors.py ......... 1077s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_contains.py ................ 1077s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_formats.py . 1077s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_interval.py ............................................ 1077s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_overlaps.py ................................................................................................................................................................. 1077s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/period/test_arithmetic.py .................................................................................... 1077s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/period/test_asfreq.py ....................... 1077s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/period/test_period.py ............................................................................................................................................................................................................................................................................................................... 1078s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/test_na_scalar.py .....................................................................................ss.....ss.....ss................................................................................................................................................................................ 1078s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/test_nat.py ........................................................................................................................s............s............................................................................................................................................................................................................................ 1078s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/methods/test_as_unit.py .... 1078s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/methods/test_round.py ................... 1079s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/test_arithmetic.py ................................................................................................................................ 1079s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/test_constructors.py ................................................................................................................................................................................................................................................................................................................... 1079s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/test_formats.py .............. 1082s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/test_timedelta.py .................................................................x............ 1082s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_as_unit.py .... 1082s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_normalize.py ................................................................................................................................................................. 1082s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_replace.py ............................................................................................................................ 1083s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_round.py ....................................................................................................................................................................................... 1083s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_timestamp_method.py . 1083s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_to_julian_date.py ..... 1083s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_to_pydatetime.py ....... 1083s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_tz_convert.py ............................................................................... 1083s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_tz_localize.py ................................................................................................................................................................................................. 1084s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_arithmetic.py ............................................................................................................. 1084s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_comparisons.py .............................. 1084s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_constructors.py ..................................................................xxx.............................................................. 1084s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_formats.py ........................................................................... 1087s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_timestamp.py .............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x....................................................................................................................................................................................................................................................................................................................................... 1087s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_timezones.py .................... 1087s 1087s =============================== warnings summary =============================== 1087s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1087s /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-1at_mcdu' 1087s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1087s 1087s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1087s /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-fq7c85qx' 1087s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1087s 1087s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1087s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 1087s ============================= slowest 30 durations ============================= 1087s 2.72s call tests/scalar/timedelta/test_timedelta.py::TestTimedeltas::test_hash_equality_invariance 1087s 0.14s call tests/scalar/timestamp/methods/test_round.py::TestTimestampRound::test_round_sanity[round] 1087s 0.14s call tests/scalar/timestamp/methods/test_round.py::TestTimestampRound::test_round_sanity[floor] 1087s 0.13s call tests/scalar/timedelta/methods/test_round.py::TestTimedeltaRound::test_round_sanity[round] 1087s 0.13s call tests/scalar/timestamp/methods/test_round.py::TestTimestampRound::test_round_sanity[ceil] 1087s 0.13s call tests/scalar/timedelta/methods/test_round.py::TestTimedeltaRound::test_round_sanity[floor] 1087s 0.11s call tests/scalar/timedelta/methods/test_round.py::TestTimedeltaRound::test_round_sanity[ceil] 1087s 0.09s call tests/scalar/timestamp/test_timestamp.py::TestTimestampProperties::test_dow_parametric 1087s 0.03s teardown tests/scalar/timestamp/test_timezones.py::TestTimestampTZOperations::test_timestamp_timetz_equivalent_with_datetime_tz[zoneinfo.ZoneInfo(key='UTC')] 1087s 0.01s call tests/scalar/test_nat.py::test_nat_vector_field_access 1087s 0.01s call tests/scalar/timestamp/test_timestamp.py::TestTimestampProperties::test_names[ne_NP.UTF-8-data1] 1087s 0.01s call tests/scalar/period/test_period.py::TestPeriodMethods::test_strftime 1087s 0.01s teardown tests/scalar/test_na_scalar.py::test_comparison_ops[le-other5] 1087s 0.01s setup tests/scalar/timestamp/test_timestamp.py::TestNonNano::test_addsub_offset[datetime.timezone(datetime.timedelta(days=-1, seconds=82800), 'foo')-ms] 1087s 0.01s teardown tests/scalar/test_nat.py::test_nat_arithmetic_index[value3-left_plus_right] 1087s 0.01s call tests/scalar/period/test_arithmetic.py::TestPeriodArithmetic::test_period_add_offset 1087s 1087s (14 durations < 0.005s hidden. Use -vv to show these durations.) 1087s =========== 4340 passed, 8 skipped, 5 xfailed, 2 warnings in 13.07s ============ 1088s rdjoqkol test state = true 1088s + echo 'rdjoqkol test state = true' 1088s + for TEST_SUBSET in $modpath/tests/* 1088s + echo /usr/lib/python3/dist-packages/pandas/tests/series 1088s + grep -q -e __pycache__ 1088s + PANDAS_CI=1 1088s + LC_ALL=C.UTF-8 1088s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/series 1088s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1088s 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" 1088s 1088s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1092s ============================= test session starts ============================== 1092s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1092s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1092s rootdir: /usr/lib/python3/dist-packages/pandas 1092s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 1092s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 1092s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1092s collected 13032 items / 2 skipped 1092s 1093s ../../../usr/lib/python3/dist-packages/pandas/tests/series/accessors/test_cat_accessor.py ................... 1100s ../../../usr/lib/python3/dist-packages/pandas/tests/series/accessors/test_dt_accessor.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1100s ../../../usr/lib/python3/dist-packages/pandas/tests/series/accessors/test_sparse_accessor.py . 1100s ../../../usr/lib/python3/dist-packages/pandas/tests/series/accessors/test_str_accessor.py .. 1100s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_datetime.py ................. 1100s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_delitem.py .... 1100s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_get.py ............ 1100s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_getitem.py .............................................................................................. 1102s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_indexing.py .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1102s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_mask.py .... 1102s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_set_value.py ... 1106s ../../../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................................................................................................................................................................................................... 1106s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_take.py .... 1106s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_where.py ......................................................................................................................................................................................................... 1106s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_xs.py ...... 1106s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_add_prefix_suffix.py ... 1107s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_align.py ............................................................................................................... 1107s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_argsort.py ......... 1107s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_asof.py ....... 1107s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_astype.py ........................................................s....s..........................................................................x........sssssssss.................s 1107s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_autocorr.py . 1107s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_between.py ....... 1107s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_case_when.py ........... 1107s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_clip.py ....s.....s.....s.....s.....s.....s.....s.....s.....s.....s............ 1107s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_combine.py . 1107s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_combine_first.py .............................. 1107s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_compare.py ............ 1109s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_convert_dtypes.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s......ss 1109s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_copy.py .......... 1109s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_count.py ... 1109s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_cov_corr.py ................ 1110s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_describe.py ...................................................... 1110s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_diff.py ....... 1110s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_drop.py ............................. 1110s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_drop_duplicates.py ..................................................................ssssss.............................................................................................................................................................................................................................................................................................................ss 1110s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_dropna.py ........... 1110s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_dtypes.py . 1110s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_duplicated.py .................. 1110s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_equals.py ..................................................... 1111s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_explode.py ...............ssss 1111s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_fillna.py ....................x.x.x................................................................................................................................. 1111s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_get_numeric_data.py . 1111s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_head_tail.py . 1111s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_infer_objects.py ....... 1111s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_info.py ........x..... 1112s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_interpolate.py x.........................................................................................................................................................................................................x.x............. 1112s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_is_monotonic.py .. 1112s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_is_unique.py ........ 1112s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_isin.py ......................................... 1112s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_isna.py .. 1112s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_item.py . 1113s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_map.py ......ss...................................xxx....................................................... 1113s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_matmul.py . 1113s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_nlargest.py ................................................................. 1113s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_nunique.py .. 1113s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_pct_change.py .............. 1113s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_pop.py . 1113s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_quantile.py ........................................ 1114s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_rank.py .......................................................................................................ssssssssssssssssssssssssssssss........................................................ssssssssssssssss.....ss.....ss.....ss.....ss.....ss.....................................................ssssssssssssssssss.............................................ssssssssssssssssss.............................................ssssssssssssssssss.............................................ssssssssssssssssss.............................................ssssssssssssssssss. 1114s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_reindex.py ................................... 1114s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_reindex_like.py .. 1114s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_rename.py ................ 1114s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_rename_axis.py ..... 1114s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_repeat.py ... 1114s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_replace.py ...........................s.......................................................................... 1115s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_reset_index.py ........s...... 1115s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_round.py ......................................................................................... 1115s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_searchsorted.py ........ 1115s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_set_name.py .. 1115s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_size.py ....... 1115s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_sort_index.py .............................................. 1115s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_sort_values.py .............. 1115s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_to_csv.py ................................... 1115s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_to_dict.py ...... 1115s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_to_frame.py ... 1115s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_to_numpy.py ...s. 1115s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_tolist.py ..........sss 1115s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_truncate.py .... 1115s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_tz_localize.py ................................................................ 1115s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_unique.py ....... 1115s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_unstack.py ....... 1115s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_update.py ....................s..... 1115s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_value_counts.py ................... 1115s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_values.py ... 1116s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_view.py .................................................. 1116s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_api.py ................................s.......................................................................................................................................................... 1123s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_arithmetic.py ..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x...............................x............. 1124s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_constructors.py ......................................................................................................................................................................................................................................x.........x............................................................................................s.................................xx.................................................sssssss.s...................... 1124s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_cumulative.py ....................................... 1125s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_formats.py .................................................. 1125s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_iteration.py ....... 1125s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_logical_ops.py ..........................xs 1125s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_missing.py ...x.. 1125s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_npfuncs.py ....s 1125s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_reductions.py ..............s............... 1125s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_subclass.py ......... 1126s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_ufunc.py .....................................................................xxxx........................................................................................................................................ 1126s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_unary.py .......................... 1127s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_validate.py ............................ 1127s 1127s =============================== warnings summary =============================== 1127s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1127s /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-o6jynu85' 1127s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1127s 1127s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1127s /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-cxp8qys4' 1127s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1127s 1127s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1127s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 1127s ============================= slowest 30 durations ============================= 1127s 0.42s call tests/series/test_formats.py::TestSeriesRepr::test_latex_repr 1127s 0.32s call tests/series/methods/test_cov_corr.py::TestSeriesCorr::test_corr[float64] 1127s 0.28s call tests/series/methods/test_rank.py::test_pct_max_many_rows 1127s 0.25s call tests/series/test_arithmetic.py::TestNamePreservation::test_series_ops_name_retention[numexpr-names3-pow-True-array0] 1127s 0.18s call tests/series/methods/test_convert_dtypes.py::TestSeriesConvertDtypes::test_convert_dtypes[test_cases16-params9] 1127s 0.14s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[chr_US.UTF-8] 1127s 0.06s call tests/series/methods/test_isin.py::TestSeriesIsIn::test_isin 1127s 0.06s teardown tests/series/test_validate.py::test_validate_bool_args[5.0-drop_duplicates] 1127s 0.03s call tests/series/test_api.py::TestSeriesMisc::test_inspect_getmembers 1127s 0.02s call tests/series/accessors/test_cat_accessor.py::TestCatAccessor::test_dt_accessor_api_for_categorical[idx1] 1127s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[br_FR.UTF-8] 1127s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ar_SA.ISO8859-6] 1127s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[da_DK.UTF-8] 1127s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ar_IQ.UTF-8] 1127s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[shn_MM.UTF-8] 1127s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ar_YE.ISO8859-6] 1127s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ar_EG.ISO8859-6] 1127s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ckb_IQ.UTF-8] 1127s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ar_OM.UTF-8] 1127s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[aa_ET.UTF-8] 1127s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[am_ET.UTF-8] 1127s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ar_JO.ISO8859-6] 1127s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ar_DZ.UTF-8] 1127s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ar_LB.UTF-8] 1127s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ar_JO.UTF-8] 1127s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ar_BH.UTF-8] 1127s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ar_SA.UTF-8] 1127s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[byn_ER.UTF-8] 1127s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ar_BH.ISO8859-6] 1127s 0.02s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ar_KW.ISO8859-6] 1127s ========= 12405 passed, 606 skipped, 23 xfailed, 2 warnings in 38.08s ========== 1128s rdjoqkol test state = true 1128s + echo 'rdjoqkol test state = true' 1128s + for TEST_SUBSET in $modpath/tests/* 1128s + echo /usr/lib/python3/dist-packages/pandas/tests/strings 1128s + grep -q -e __pycache__ 1128s + PANDAS_CI=1 1128s + LC_ALL=C.UTF-8 1128s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/strings 1129s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1129s 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" 1129s 1129s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1130s ============================= test session starts ============================== 1130s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1130s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1130s rootdir: /usr/lib/python3/dist-packages/pandas 1130s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 1130s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 1130s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1130s collected 3604 items 1130s 1134s ../../../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 1134s ../../../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 1134s ../../../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...................................... 1135s ../../../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 1136s ../../../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 1136s ../../../usr/lib/python3/dist-packages/pandas/tests/strings/test_get_dummies.py ..ss...ss. 1136s ../../../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 1136s ../../../usr/lib/python3/dist-packages/pandas/tests/strings/test_string_array.py ...............................................................................sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss....ssss....ssss.s 1137s ../../../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....... 1137s 1137s =============================== warnings summary =============================== 1137s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1137s /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-4zgxltek' 1137s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1137s 1137s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1137s /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-xw7emg6a' 1137s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1137s 1137s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1137s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 1137s ============================= slowest 30 durations ============================= 1137s 0.11s call tests/strings/test_strings.py::test_ismethods[string[python]-isalpha-expected1] 1137s 0.02s call tests/strings/test_strings.py::test_empty_str_methods[string[python]] 1137s 0.01s teardown tests/strings/test_strings.py::test_series_str_decode 1137s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data7-names7] 1137s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data6-names6] 1137s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data5-names5] 1137s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data2-names2] 1137s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data3-names3] 1137s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data7-names7] 1137s 0.01s call tests/strings/test_strings.py::test_empty_str_methods[object] 1137s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data5-names5] 1137s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data0-names0] 1137s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data2-names2] 1137s 0.01s call tests/strings/test_extract.py::test_extractall_same_as_extract_subject_index[string[python]] 1137s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data4-names4] 1137s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data1-names1] 1137s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data6-names6] 1137s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data3-names3] 1137s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data0-names0] 1137s 0.01s call tests/strings/test_extract.py::test_extractall_same_as_extract_subject_index[object] 1137s 0.01s call tests/strings/test_extract.py::test_extract_expand_capture_groups[string[python]] 1137s 0.01s call tests/strings/test_extract.py::test_extractall[string[python]] 1137s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data1-names1] 1137s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data4-names4] 1137s 0.01s call tests/strings/test_extract.py::test_extractall_same_as_extract[string[python]] 1137s 0.01s call tests/strings/test_extract.py::test_extract_expand_capture_groups[object] 1137s 0.01s call tests/strings/test_extract.py::test_extractall[object] 1137s 0.01s call tests/strings/test_cat.py::test_str_cat_mixed_inputs[index] 1137s 0.01s call tests/strings/test_extract.py::test_extractall_same_as_extract[object] 1137s 0.01s call tests/strings/test_string_array.py::test_string_array[string[python]-match] 1137s ========== 2704 passed, 887 skipped, 13 xfailed, 2 warnings in 7.72s =========== 1137s rdjoqkol test state = true 1137s + echo 'rdjoqkol test state = true' 1137s + for TEST_SUBSET in $modpath/tests/* 1137s + echo /usr/lib/python3/dist-packages/pandas/tests/test_aggregation.py 1137s + grep -q -e __pycache__ 1137s + PANDAS_CI=1 1137s + LC_ALL=C.UTF-8 1137s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_aggregation.py 1138s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1138s 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" 1138s 1138s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1138s ============================= test session starts ============================== 1138s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1138s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1138s rootdir: /usr/lib/python3/dist-packages/pandas 1138s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 1138s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 1138s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1138s collected 8 items 1138s 1138s ../../../usr/lib/python3/dist-packages/pandas/tests/test_aggregation.py ........ 1138s 1138s =============================== warnings summary =============================== 1138s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1138s /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-xpec6k79' 1138s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1138s 1138s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1138s /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-im_c0hww' 1138s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1138s 1138s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1138s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 1138s ============================= slowest 30 durations ============================= 1138s 1138s (24 durations < 0.005s hidden. Use -vv to show these durations.) 1138s ======================== 8 passed, 2 warnings in 0.10s ========================= 1138s + echo 'rdjoqkol test state = true' 1138s rdjoqkol test state = true 1138s + for TEST_SUBSET in $modpath/tests/* 1138s + echo /usr/lib/python3/dist-packages/pandas/tests/test_algos.py 1138s + grep -q -e __pycache__ 1138s + PANDAS_CI=1 1138s + LC_ALL=C.UTF-8 1138s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_algos.py 1139s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1139s 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" 1139s 1139s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1140s ============================= test session starts ============================== 1140s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1140s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1140s rootdir: /usr/lib/python3/dist-packages/pandas 1140s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 1140s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 1140s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1140s collected 471 items 1140s 1142s ../../../usr/lib/python3/dist-packages/pandas/tests/test_algos.py ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1142s 1142s =============================== warnings summary =============================== 1142s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1142s /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-eur4aqvj' 1142s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1142s 1142s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1142s /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-d61m0drb' 1142s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1142s 1142s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1142s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 1142s ============================= slowest 30 durations ============================= 1142s 1.30s call tests/test_algos.py::TestRank::test_pct_max_many_rows 1142s 0.47s call tests/test_algos.py::TestRank::test_scipy_compat[arr0] 1142s 0.02s call tests/test_algos.py::TestDuplicated::test_datetime_likes 1142s 0.01s call tests/test_algos.py::TestIsin::test_large 1142s 0.01s call tests/test_algos.py::TestUnique::test_object_refcount_bug 1142s 0.01s setup tests/test_algos.py::TestUnique::test_dtype_preservation[float32] 1142s 0.01s call tests/test_algos.py::TestIsin::test_same_nan_is_in_large_series 1142s 0.01s call tests/test_algos.py::TestMode::test_no_mode 1142s 0.01s call tests/test_algos.py::TestIsin::test_same_nan_is_in_large 1142s 1142s (21 durations < 0.005s hidden. Use -vv to show these durations.) 1142s ======================= 471 passed, 2 warnings in 2.90s ======================== 1143s rdjoqkol test state = true 1143s + echo 'rdjoqkol test state = true' 1143s + for TEST_SUBSET in $modpath/tests/* 1143s + echo /usr/lib/python3/dist-packages/pandas/tests/test_common.py 1143s + grep -q -e __pycache__ 1143s + PANDAS_CI=1 1143s + LC_ALL=C.UTF-8 1143s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_common.py 1143s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1143s 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" 1143s 1143s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1144s ============================= test session starts ============================== 1144s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1144s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1144s rootdir: /usr/lib/python3/dist-packages/pandas 1144s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 1144s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 1144s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1144s collected 128 items 1144s 1145s ../../../usr/lib/python3/dist-packages/pandas/tests/test_common.py ...............x.x.............................................................................................................. 1145s 1145s =============================== warnings summary =============================== 1145s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1145s /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-c8i0a3xr' 1145s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1145s 1145s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1145s /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-i_dmhhxp' 1145s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1145s 1145s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1145s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 1145s ============================= slowest 30 durations ============================= 1145s 0.56s call tests/test_common.py::test_bz2_missing_import 1145s 0.45s call tests/test_common.py::test_str_size 1145s 0.01s call tests/test_common.py::test_serializable[obj71] 1145s 1145s (27 durations < 0.005s hidden. Use -vv to show these durations.) 1145s ================== 126 passed, 2 xfailed, 2 warnings in 1.36s ================== 1145s rdjoqkol test state = true 1145s + echo 'rdjoqkol test state = true' 1145s + for TEST_SUBSET in $modpath/tests/* 1145s + echo /usr/lib/python3/dist-packages/pandas/tests/test_downstream.py 1145s + grep -q -e __pycache__ 1145s + PANDAS_CI=1 1145s + LC_ALL=C.UTF-8 1145s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_downstream.py 1146s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1146s 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" 1146s 1146s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1146s ============================= test session starts ============================== 1146s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1146s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1146s rootdir: /usr/lib/python3/dist-packages/pandas 1146s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 1146s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 1146s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1146s collected 26 items 1146s 1150s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py ....s..sssss.sx.........s. 1150s 1150s =============================== warnings summary =============================== 1150s tests/test_downstream.py::test_dask 1150s /usr/lib/python3/dist-packages/dask/dataframe/__init__.py:49: FutureWarning: 1150s Dask dataframe query planning is disabled because dask-expr is not installed. 1150s 1150s You can install it with `pip install dask[dataframe]` or `conda install dask`. 1150s This will raise in a future version. 1150s 1150s warnings.warn(msg, FutureWarning) 1150s 1150s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1150s /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-3pa3npc9' 1150s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1150s 1150s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1150s /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-1o1wqxzx' 1150s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1150s 1150s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1150s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 1150s ============================= slowest 30 durations ============================= 1150s 1.93s call tests/test_downstream.py::test_oo_optimized_datetime_index_unpickle 1150s 1.89s call tests/test_downstream.py::test_oo_optimizable 1150s 0.11s call tests/test_downstream.py::test_dask 1150s 0.02s call tests/test_downstream.py::test_construct_dask_float_array_int_dtype_match_ndarray 1150s 0.01s call tests/test_downstream.py::test_yaml_dump 1150s 0.01s call tests/test_downstream.py::test_frame_setitem_dask_array_into_new_col 1150s 0.01s call tests/test_downstream.py::test_dask_ufunc 1150s 1150s (23 durations < 0.005s hidden. Use -vv to show these durations.) 1150s ============= 17 passed, 8 skipped, 1 xfailed, 3 warnings in 4.58s ============= 1151s rdjoqkol test state = true 1151s + echo 'rdjoqkol test state = true' 1151s + for TEST_SUBSET in $modpath/tests/* 1151s + echo /usr/lib/python3/dist-packages/pandas/tests/test_errors.py 1151s + grep -q -e __pycache__ 1151s + PANDAS_CI=1 1151s + LC_ALL=C.UTF-8 1151s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_errors.py 1152s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1152s 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" 1152s 1152s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1152s ============================= test session starts ============================== 1152s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1152s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1152s rootdir: /usr/lib/python3/dist-packages/pandas 1152s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 1152s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 1152s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1152s collected 36 items 1152s 1152s ../../../usr/lib/python3/dist-packages/pandas/tests/test_errors.py .................................... 1152s 1152s =============================== warnings summary =============================== 1152s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1152s /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-tj8vkiu7' 1152s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1152s 1152s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1152s /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-llihy8rq' 1152s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1152s 1152s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1152s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 1152s ============================= slowest 30 durations ============================= 1152s 1152s (30 durations < 0.005s hidden. Use -vv to show these durations.) 1152s ======================== 36 passed, 2 warnings in 0.13s ======================== 1152s rdjoqkol test state = true 1152s + echo 'rdjoqkol test state = true' 1152s + for TEST_SUBSET in $modpath/tests/* 1152s + echo /usr/lib/python3/dist-packages/pandas/tests/test_expressions.py 1152s + grep -q -e __pycache__ 1152s + PANDAS_CI=1 1152s + LC_ALL=C.UTF-8 1152s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_expressions.py 1153s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1153s 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" 1153s 1153s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1153s ============================= test session starts ============================== 1153s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1153s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1153s rootdir: /usr/lib/python3/dist-packages/pandas 1153s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 1153s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 1153s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1153s collected 243 items 1153s 1154s ../../../usr/lib/python3/dist-packages/pandas/tests/test_expressions.py ................................................................................................................................................................................................................................................... 1154s 1154s =============================== warnings summary =============================== 1154s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1154s /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-_am7_jhm' 1154s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1154s 1154s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1154s /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-mstpezqi' 1154s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1154s 1154s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1154s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 1154s ============================= slowest 30 durations ============================= 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_invalid 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[le-True-_frame2] 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-False-_integer_integers] 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-False-_mixed] 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[ge-False-_mixed] 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[lt-True-_mixed] 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[mod-False-_integer_integers] 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[eq-True-_mixed] 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[sub-False-_mixed] 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[ne-False-_mixed] 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[gt-False-_mixed] 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[truediv-False-_mixed] 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[lt-True-_frame] 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[le-False-_mixed] 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[mod-False-_mixed] 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[eq-False-_mixed] 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[lt-False-_mixed] 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[add-False-_mixed] 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[truediv-True-_mixed] 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[ne-True-_mixed] 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[ge-True-_mixed] 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[le-True-_mixed] 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-True-_mixed] 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[gt-True-_mixed] 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[add-True-_mixed] 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[mod-True-_integer_integers] 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[mul-False-_mixed] 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-True-_integer_integers] 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[mod-True-_mixed] 1154s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[mul-True-_mixed] 1154s ======================= 243 passed, 2 warnings in 1.31s ======================== 1155s + echo 'rdjoqkol test state = true' 1155s + for TEST_SUBSET in $modpath/tests/* 1155s rdjoqkol test state = true 1155s + echo /usr/lib/python3/dist-packages/pandas/tests/test_flags.py 1155s + grep -q -e __pycache__ 1155s + PANDAS_CI=1 1155s + LC_ALL=C.UTF-8 1155s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_flags.py 1155s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1155s 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" 1155s 1155s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1155s ============================= test session starts ============================== 1155s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1155s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1155s rootdir: /usr/lib/python3/dist-packages/pandas 1155s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 1155s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 1155s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1155s collected 5 items 1155s 1155s ../../../usr/lib/python3/dist-packages/pandas/tests/test_flags.py ..... 1155s 1155s =============================== warnings summary =============================== 1155s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1155s /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-_6hz9ief' 1155s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1155s 1155s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1155s /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-mg14uakd' 1155s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1155s 1155s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1155s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 1155s ============================= slowest 30 durations ============================= 1155s 1155s (15 durations < 0.005s hidden. Use -vv to show these durations.) 1155s ======================== 5 passed, 2 warnings in 0.10s ========================= 1156s + echo 'rdjoqkol test state = true' 1156s + for TEST_SUBSET in $modpath/tests/* 1156s rdjoqkol test state = true 1156s + echo /usr/lib/python3/dist-packages/pandas/tests/test_multilevel.py 1156s + grep -q -e __pycache__ 1156s + PANDAS_CI=1 1156s + LC_ALL=C.UTF-8 1156s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_multilevel.py 1157s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1157s 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" 1157s 1157s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1157s ============================= test session starts ============================== 1157s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1157s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1157s rootdir: /usr/lib/python3/dist-packages/pandas 1157s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 1157s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 1157s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1157s collected 19 items 1157s 1157s ../../../usr/lib/python3/dist-packages/pandas/tests/test_multilevel.py ................... 1157s 1157s =============================== warnings summary =============================== 1157s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1157s /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-9tb4yxwy' 1157s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1157s 1157s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1157s /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-j7yjmbbx' 1157s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1157s 1157s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1157s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 1157s ============================= slowest 30 durations ============================= 1157s 0.01s call tests/test_multilevel.py::TestMultiLevel::test_reindex_level 1157s 0.01s call tests/test_multilevel.py::TestMultiLevel::test_alignment 1157s 0.01s call tests/test_multilevel.py::TestMultiLevel::test_reindex_level_partial_selection 1157s 0.01s setup tests/test_multilevel.py::TestMultiLevel::test_reindex_level 1157s 1157s (26 durations < 0.005s hidden. Use -vv to show these durations.) 1157s ======================== 19 passed, 2 warnings in 0.22s ======================== 1157s + echo 'rdjoqkol test state = true' 1157s + for TEST_SUBSET in $modpath/tests/* 1157s rdjoqkol test state = true 1157s + echo /usr/lib/python3/dist-packages/pandas/tests/test_nanops.py 1157s + grep -q -e __pycache__ 1157s + PANDAS_CI=1 1157s + LC_ALL=C.UTF-8 1157s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_nanops.py 1158s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1158s 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" 1158s 1158s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1158s ============================= test session starts ============================== 1158s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1158s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1158s rootdir: /usr/lib/python3/dist-packages/pandas 1158s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 1158s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 1158s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1158s collected 245 items 1158s 1159s ../../../usr/lib/python3/dist-packages/pandas/tests/test_nanops.py ..................................................................................................................................................................................................................................................... 1159s 1159s =============================== warnings summary =============================== 1159s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1159s /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-2ru9cd57' 1159s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1159s 1159s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1159s /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-l0wqoy9f' 1159s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1159s 1159s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1159s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 1159s ============================= slowest 30 durations ============================= 1159s 0.37s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[True-0] 1159s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nankurt[True] 1159s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nanskew[True] 1159s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[True-1] 1159s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[True-2] 1159s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nankurt[False] 1159s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nancorr_spearman 1159s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nanskew[False] 1159s 0.02s call tests/test_nanops.py::TestnanopsDataFrame::test_nanmedian[True] 1159s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[False-2] 1159s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[False-0] 1159s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[False-1] 1159s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanmedian[False] 1159s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanstd[True-2] 1159s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanstd[True-1] 1159s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanstd[True-0] 1159s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanvar[True-0] 1159s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanvar[True-2] 1159s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanvar[True-1] 1159s 1159s (11 durations < 0.005s hidden. Use -vv to show these durations.) 1159s ======================= 245 passed, 2 warnings in 1.22s ======================== 1159s + echo 'rdjoqkol test state = true' 1159s rdjoqkol test state = true 1159s + for TEST_SUBSET in $modpath/tests/* 1159s + echo /usr/lib/python3/dist-packages/pandas/tests/test_optional_dependency.py 1159s + grep -q -e __pycache__ 1159s + PANDAS_CI=1 1159s + LC_ALL=C.UTF-8 1159s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_optional_dependency.py 1160s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1160s 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" 1160s 1160s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1160s ============================= test session starts ============================== 1160s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1160s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1160s rootdir: /usr/lib/python3/dist-packages/pandas 1160s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 1160s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 1160s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1160s collected 5 items 1160s 1160s ../../../usr/lib/python3/dist-packages/pandas/tests/test_optional_dependency.py ..... 1160s 1160s =============================== warnings summary =============================== 1160s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1160s /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-72bbld_s' 1160s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1160s 1160s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1160s /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-tjrsv4kb' 1160s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1160s 1160s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1160s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 1160s ============================= slowest 30 durations ============================= 1160s 0.01s call tests/test_optional_dependency.py::test_xlrd_version_fallback 1160s 1160s (14 durations < 0.005s hidden. Use -vv to show these durations.) 1160s ======================== 5 passed, 2 warnings in 0.10s ========================= 1161s rdjoqkol test state = true 1161s + echo 'rdjoqkol test state = true' 1161s + for TEST_SUBSET in $modpath/tests/* 1161s + echo /usr/lib/python3/dist-packages/pandas/tests/test_register_accessor.py 1161s + grep -q -e __pycache__ 1161s + PANDAS_CI=1 1161s + LC_ALL=C.UTF-8 1161s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_register_accessor.py 1161s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1161s 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" 1161s 1161s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1161s ============================= test session starts ============================== 1161s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1161s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1161s rootdir: /usr/lib/python3/dist-packages/pandas 1161s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 1161s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 1161s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1161s collected 7 items 1161s 1161s ../../../usr/lib/python3/dist-packages/pandas/tests/test_register_accessor.py ....... 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-znxu8fwq' 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-rplv00sb' 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.k7pV9B/autopkgtest_tmp/test-data.xml --- 1161s ============================= slowest 30 durations ============================= 1161s 1161s (21 durations < 0.005s hidden. Use -vv to show these durations.) 1161s ======================== 7 passed, 2 warnings in 0.11s ========================= 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/test_sorting.py 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.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_sorting.py 1163s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1163s 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" 1163s 1163s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1163s ============================= test session starts ============================== 1163s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1163s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1163s rootdir: /usr/lib/python3/dist-packages/pandas 1163s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 1163s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 1163s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1163s collected 54 items / 15 deselected / 39 selected 1163s 1164s ../../../usr/lib/python3/dist-packages/pandas/tests/test_sorting.py ....................................... 1164s 1164s =============================== warnings summary =============================== 1164s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1164s /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-zsxu_bcp' 1164s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1164s 1164s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1164s /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-2j_p_ac3' 1164s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1164s 1164s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1164s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 1164s ============================= slowest 30 durations ============================= 1164s 0.80s call tests/test_sorting.py::TestSorting::test_int64_overflow_groupby_large_range 1164s 0.29s call tests/test_sorting.py::TestSorting::test_int64_overflow_groupby_large_df_shuffled[median] 1164s 0.29s call tests/test_sorting.py::TestSorting::test_int64_overflow_groupby_large_df_shuffled[mean] 1164s 0.01s call tests/test_sorting.py::TestMerge::test_int64_overflow_outer_merge 1164s 1164s (26 durations < 0.005s hidden. Use -vv to show these durations.) 1164s ================ 39 passed, 15 deselected, 2 warnings in 1.58s ================= 1164s rdjoqkol test state = true 1164s + echo 'rdjoqkol test state = true' 1164s + for TEST_SUBSET in $modpath/tests/* 1164s + echo /usr/lib/python3/dist-packages/pandas/tests/test_take.py 1164s + grep -q -e __pycache__ 1164s + PANDAS_CI=1 1164s + LC_ALL=C.UTF-8 1164s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_take.py 1165s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1165s 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" 1165s 1165s 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.k7pV9B/build.APd/src/pyproject.toml 1165s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 1165s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1165s collected 81 items 1165s 1165s ../../../usr/lib/python3/dist-packages/pandas/tests/test_take.py ................................................................................. 1165s 1165s =============================== warnings summary =============================== 1165s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1165s /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-0vkq8zm1' 1165s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1165s 1165s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1165s /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-a29jnez0' 1165s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1165s 1165s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1165s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 1165s ============================= slowest 30 durations ============================= 1165s 1165s (30 durations < 0.005s hidden. Use -vv to show these durations.) 1165s ======================== 81 passed, 2 warnings in 0.22s ======================== 1166s + echo 'rdjoqkol test state = true' 1166s rdjoqkol test state = true 1166s + for TEST_SUBSET in $modpath/tests/* 1166s + echo /usr/lib/python3/dist-packages/pandas/tests/tools 1166s + grep -q -e __pycache__ 1166s + PANDAS_CI=1 1166s + LC_ALL=C.UTF-8 1166s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/tools 1166s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1166s 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" 1166s 1166s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1167s ============================= test session starts ============================== 1167s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1167s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1167s rootdir: /usr/lib/python3/dist-packages/pandas 1167s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 1167s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 1167s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1167s collected 1510 items 1167s 1170s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_datetime.py ..................................................................................................................................................................................................................................ssssssss....................................................................ss................................................................................................................................................................................................................................................................................xx..........................................................................................................................................................................................................................................................................................................................................................................ssssssssss............................ 1171s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_numeric.py ...s.s....................................................................................................................................................................................................................................................xx.......................................................................................................................ssssss.s.s.................................sss...sss.s....ssss.s.s 1171s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_time.py ........... 1171s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_timedelta.py ........................................................................ssssssssssss 1171s 1171s =============================== warnings summary =============================== 1171s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1171s /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-g4kzjqz9' 1171s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1171s 1171s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1171s /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-4dtqrxc6' 1171s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1171s 1171s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1171s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 1171s ============================= slowest 30 durations ============================= 1171s 0.08s 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] 1171s 0.07s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[array-None-True] 1171s 0.07s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[array-%Y%m%d %H:%M:%S-True] 1171s 0.07s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[array-None-None] 1171s 0.07s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[array-%Y%m%d %H:%M:%S-None] 1171s 0.06s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[list-%Y%m%d %H:%M:%S-True] 1171s 0.06s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[list-%Y%m%d %H:%M:%S-None] 1171s 0.06s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[deque-None-True] 1171s 0.06s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[deque-None-None] 1171s 0.06s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[deque-%Y%m%d %H:%M:%S-True] 1171s 0.06s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[deque-%Y%m%d %H:%M:%S-None] 1171s 0.06s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[list-None-None] 1171s 0.06s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[list-None-True] 1171s 0.06s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[tuple-%Y%m%d %H:%M:%S-True] 1171s 0.06s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[tuple-None-None] 1171s 0.06s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[tuple-None-True] 1171s 0.06s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[tuple-%Y%m%d %H:%M:%S-None] 1171s 0.03s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[Index-None-None] 1171s 0.03s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[Index-None-True] 1171s 0.03s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache_series[None-True] 1171s 0.03s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache_series[None-None] 1171s 0.03s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[Index-%Y%m%d %H:%M:%S-True] 1171s 0.03s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[Index-%Y%m%d %H:%M:%S-None] 1171s 0.03s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache_series[%Y%m%d %H:%M:%S-None] 1171s 0.03s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache_series[%Y%m%d %H:%M:%S-True] 1171s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_fixed_offset 1171s 0.01s call tests/tools/test_to_datetime.py::TestToDatetimeMisc::test_to_datetime_timezone_name 1171s 0.01s teardown tests/tools/test_to_timedelta.py::test_from_timedelta_arrow_dtype[ms] 1171s 0.01s setup tests/tools/test_to_timedelta.py::TestTimedeltas::test_to_timedelta_precision_over_nanos[to_timedelta-8:53:08.71800000001-8:53:08.718] 1171s 0.01s call tests/tools/test_to_datetime.py::TestToDatetimeDataFrame::test_dataframe[True] 1171s =========== 1451 passed, 55 skipped, 4 xfailed, 2 warnings in 4.60s ============ 1171s + echo 'rdjoqkol test state = true' 1171s + for TEST_SUBSET in $modpath/tests/* 1171s + echo /usr/lib/python3/dist-packages/pandas/tests/tseries 1171s rdjoqkol test state = true 1171s + grep -q -e __pycache__ 1171s + PANDAS_CI=1 1171s + LC_ALL=C.UTF-8 1171s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/tseries 1172s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1172s 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" 1172s 1172s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1173s ============================= test session starts ============================== 1173s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1173s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1173s rootdir: /usr/lib/python3/dist-packages/pandas 1173s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 1173s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 1173s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1173s collected 5480 items 1173s 1173s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/frequencies/test_freq_code.py ................... 1173s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/frequencies/test_frequencies.py .......... 1175s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/frequencies/test_inference.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1175s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/holiday/test_calendar.py ........ 1175s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/holiday/test_federal.py ... 1176s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/holiday/test_holiday.py ................................................. 1176s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/holiday/test_observance.py ................................. 1176s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_day.py ....................... 1176s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_hour.py .............................................................................................. 1176s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_month.py ..................... 1176s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_quarter.py .............................................. 1176s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_year.py ................... 1177s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_common.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1177s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_custom_business_day.py ....... 1177s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_custom_business_hour.py ............................ 1177s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_custom_business_month.py .................................................... 1177s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_dst.py .......................... 1177s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_easter.py .......... 1177s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_fiscal.py ............................................................................................................................................. 1178s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_index.py ........................ 1178s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_month.py ............................................................ 1183s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_offsets.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x..................................................................................................................................................................................................................................................x................................................................................................................................................................................................................................................ 1184s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_offsets_properties.py .. 1184s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_quarter.py ........................................................................................ 1186s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_ticks.py ............................................................................................................ 1186s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_week.py .............................................. 1186s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_year.py ................................. 1186s 1186s =============================== warnings summary =============================== 1186s tests/tseries/offsets/test_offsets_properties.py::test_on_offset_implementations 1186s /usr/lib/python3/dist-packages/dateutil/zoneinfo/__init__.py:26: UserWarning: I/O error(2): No such file or directory 1186s warnings.warn("I/O error({0}): {1}".format(e.errno, e.strerror)) 1186s 1186s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1186s /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-fwk1qwbc' 1186s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1186s 1186s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1186s /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-nkww_ona' 1186s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1186s 1186s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1186s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 1186s ============================= slowest 30 durations ============================= 1186s 0.48s call tests/tseries/offsets/test_offsets_properties.py::test_on_offset_implementations 1186s 0.36s call tests/tseries/offsets/test_offsets_properties.py::test_shift_across_dst 1186s 0.26s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Second] 1186s 0.21s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Micro] 1186s 0.21s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Nano] 1186s 0.21s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Milli] 1186s 0.21s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Hour] 1186s 0.20s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Second] 1186s 0.20s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Minute] 1186s 0.11s call tests/tseries/offsets/test_custom_business_hour.py::TestCustomBusinessHour::test_us_federal_holiday_with_datetime 1186s 0.11s call tests/tseries/offsets/test_custom_business_day.py::TestCustomBusinessDay::test_calendar 1186s 0.10s call tests/tseries/offsets/test_common.py::test_apply_out_of_range[pytz.FixedOffset(-300)-MonthBegin] 1186s 0.09s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Nano] 1186s 0.09s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Micro] 1186s 0.09s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Hour] 1186s 0.08s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Milli] 1186s 0.08s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Minute] 1186s 0.04s call tests/tseries/offsets/test_index.py::test_apply_index[BYearEnd--2] 1186s 0.04s call tests/tseries/offsets/test_business_month.py::test_apply_index[BusinessMonthBegin--2] 1186s 0.04s call tests/tseries/offsets/test_index.py::test_apply_index[BusinessMonthBegin--2] 1186s 0.04s call tests/tseries/offsets/test_index.py::test_apply_index[BQuarterBegin--2] 1186s 0.04s call tests/tseries/offsets/test_index.py::test_apply_index[BYearBegin--2] 1186s 0.04s call tests/tseries/offsets/test_index.py::test_apply_index[BQuarterEnd--2] 1186s 0.04s call tests/tseries/offsets/test_index.py::test_apply_index[YearEnd--2] 1186s 0.04s call tests/tseries/offsets/test_index.py::test_apply_index[QuarterBegin--2] 1186s 0.04s call tests/tseries/offsets/test_index.py::test_apply_index[YearBegin--2] 1186s 0.04s call tests/tseries/offsets/test_index.py::test_apply_index[MonthBegin--2] 1186s 0.04s call tests/tseries/offsets/test_index.py::test_apply_index[QuarterEnd--2] 1186s 0.03s call tests/tseries/offsets/test_business_month.py::test_apply_index[BusinessMonthEnd-1] 1186s 0.03s call tests/tseries/offsets/test_index.py::test_apply_index[BusinessMonthEnd-1] 1186s ================= 5478 passed, 2 xfailed, 3 warnings in 13.87s ================= 1187s rdjoqkol test state = true 1187s + echo 'rdjoqkol test state = true' 1187s + for TEST_SUBSET in $modpath/tests/* 1187s + echo /usr/lib/python3/dist-packages/pandas/tests/tslibs 1187s + grep -q -e __pycache__ 1187s + PANDAS_CI=1 1187s + LC_ALL=C.UTF-8 1187s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/tslibs 1188s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1188s 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" 1188s 1188s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1188s ============================= test session starts ============================== 1188s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1188s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1188s rootdir: /usr/lib/python3/dist-packages/pandas 1188s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 1188s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 1188s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1188s collected 1140 items 1188s 1188s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_api.py . 1188s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_array_to_datetime.py ............................................ 1188s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_ccalendar.py ................. 1191s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_conversion.py ...................................................................... 1191s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_fields.py .... 1191s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_libfrequencies.py ............ 1192s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_liboffsets.py .......................................................................... 1192s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_np_datetime.py ........ 1192s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_npy_units.py .. 1192s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_parse_iso8601.py ................................................... 1198s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_parsing.py .............................................................................................................................................x...x................................. 1198s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_period.py ....................................... 1198s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_resolution.py ................... 1198s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_strptime.py ....... 1198s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_timedeltas.py ......................... 1199s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_timezones.py ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 1199s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_to_offset.py ................................................................................................... 1199s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_tzconversion.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-fzynib5l' 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-bdkp7_06' 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.k7pV9B/autopkgtest_tmp/test-data.xml --- 1199s ============================= slowest 30 durations ============================= 1199s 0.32s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%m %Y-False-.] 1199s 0.32s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['dateutil/Asia/Singapore'] 1199s 0.29s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%m %Y-True-.] 1199s 0.23s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[tzlocal()] 1199s 0.22s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-True-.] 1199s 0.22s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['-02:15'] 1199s 0.21s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['+01:15'] 1199s 0.21s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['UTC+01:15'] 1199s 0.21s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['UTC-02:15'] 1199s 0.21s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[datetime.timezone(datetime.timedelta(days=-1, seconds=82800), 'foo')] 1199s 0.21s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[datetime.timezone(datetime.timedelta(seconds=3600))] 1199s 0.19s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[pytz.FixedOffset(-300)] 1199s 0.19s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[pytz.FixedOffset(300)] 1199s 0.16s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%m %d %Y-False--] 1199s 0.15s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['Asia/Tokyo'] 1199s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-False-/] 1199s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-False--] 1199s 0.11s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-False- ] 1199s 0.11s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-True- ] 1199s 0.11s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y%m%d-True--] 1199s 0.11s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-True--] 1199s 0.11s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-False- ] 1199s 0.11s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-False-.] 1199s 0.11s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y%m%d-True-/] 1199s 0.11s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-True-/] 1199s 0.11s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-True--] 1199s 0.11s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-True- ] 1199s 0.11s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y%m%d-False-.] 1199s 0.11s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-True-/] 1199s 0.11s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y%m%d-False-/] 1199s ================= 1138 passed, 2 xfailed, 2 warnings in 11.48s ================= 1200s + echo 'rdjoqkol test state = true' 1200s + for TEST_SUBSET in $modpath/tests/* 1200s + echo /usr/lib/python3/dist-packages/pandas/tests/util 1200s + grep -q -e __pycache__ 1200s + PANDAS_CI=1 1200s + LC_ALL=C.UTF-8 1200s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/util 1200s rdjoqkol test state = true 1201s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1201s 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" 1201s 1201s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1201s ============================= test session starts ============================== 1201s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1201s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1201s rootdir: /usr/lib/python3/dist-packages/pandas 1201s configfile: ../../../../../tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml 1201s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 1201s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1201s collected 916 items 1201s 1201s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_almost_equal.py .................................................................................................................................................................... 1201s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_attr_equal.py .......................................... 1201s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_categorical_equal.py .......... 1201s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_extension_array_equal.py ..................... 1201s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_frame_equal.py ............................................................................................................... 1202s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_index_equal.py ................................................................ 1202s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_interval_array_equal.py ....... 1202s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_numpy_array_equal.py ......................... 1202s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_produces_warning.py ............................................................................................................................ 1202s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_series_equal.py .............................................................................................. 1202s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_deprecate.py ... 1202s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_deprecate_kwarg.py .............. 1202s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_deprecate_nonkeyword_arguments.py ................... 1202s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_doc.py .... 1202s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_hashing.py ..................................................................................................................................................... 1202s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_numba.py . 1202s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_rewrite_warning.py .......... 1202s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_shares_memory.py .s 1203s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_show_versions.py .... 1203s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_util.py ...sx.. 1203s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_validate_args.py ...... 1203s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_validate_args_and_kwargs.py ...... 1203s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_validate_inclusive.py ........... 1203s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_validate_kwargs.py .................. 1203s 1203s =============================== warnings summary =============================== 1203s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1203s /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-szzvzc2u' 1203s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1203s 1203s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1203s /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-1neo275v' 1203s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1203s 1203s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1203s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 1203s ============================= slowest 30 durations ============================= 1203s 0.74s call tests/util/test_show_versions.py::test_show_versions 1203s 0.02s call tests/util/test_hashing.py::test_same_len_hash_collisions[0-7] 1203s 0.02s call tests/util/test_hashing.py::test_same_len_hash_collisions[1-7] 1203s 0.01s call tests/util/test_hashing.py::test_same_len_hash_collisions[0-6] 1203s 0.01s call tests/util/test_hashing.py::test_same_len_hash_collisions[1-6] 1203s 0.01s call tests/util/test_assert_series_equal.py::test_series_equal_length_mismatch[0.0005] 1203s 0.01s call tests/util/test_show_versions.py::test_show_versions_console_json 1203s 0.01s call tests/util/test_show_versions.py::test_json_output_match 1203s 1203s (22 durations < 0.005s hidden. Use -vv to show these durations.) 1203s ============ 913 passed, 2 skipped, 1 xfailed, 2 warnings in 2.64s ============= 1204s + echo 'rdjoqkol test state = true' 1204s + for TEST_SUBSET in $modpath/tests/* 1204s + echo /usr/lib/python3/dist-packages/pandas/tests/window 1204s + grep -q -e __pycache__ 1204s rdjoqkol test state = true 1204s + PANDAS_CI=1 1204s + LC_ALL=C.UTF-8 1204s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.k7pV9B/build.APd/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.k7pV9B/build.APd/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/window 1205s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1205s 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" 1205s 1205s 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.k7pV9B/build.APd/src/pyproject.toml 1206s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 1206s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1206s collected 10242 items / 536 deselected / 1 skipped / 9706 selected 1206s 1209s ../../../usr/lib/python3/dist-packages/pandas/tests/window/moments/test_moments_consistency_ewm.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 1210s ../../../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................................................................................................................................................................................................................................................................................ 1212s ../../../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................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 1214s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_api.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1215s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_apply.py ...s....sssss..........s..s....................................................... 1216s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_base_indexer.py .................................................................................................................................................................................................................................... 1216s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_cython_aggregations.py ........................................................................ 1220s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_dtypes.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1221s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_ewm.py .......................................................................................................................................................................................................................................ssssssssssss........ssssssssssssssss................ 1222s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_expanding.py ..........x................................................................................................................................................................................................ss....s...................s..s......s............................................................................................. 1223s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_groupby.py ................................................................................................................... 1223s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 1226s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_pairwise.py ........................................................................................................................................................................................................................................................................................................................ 1228s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling.py .........................................................................................................................................................................................................................................................................................................................................................................................xxxx........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1230s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_functions.py .................................................................................................................................................................................................................................................................................................................................................................................................................................. 1231s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_quantile.py .......................................................................................................................................................................................... 1231s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_skew_kurt.py .................................................................... 1232s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_timeseries_window.py ..................................................................................s 1232s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_win_type.py ............................................................................................................................................................................................................................................................................................... 1232s 1232s =============================== warnings summary =============================== 1232s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1232s /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-mrz72sk_' 1232s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1232s 1232s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1232s /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-8zoxs1ou' 1232s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1232s 1232s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1232s -- generated xml file: /tmp/autopkgtest.k7pV9B/autopkgtest_tmp/test-data.xml --- 1232s ============================= slowest 30 durations ============================= 1232s 0.41s call tests/window/test_apply.py::test_time_rule_frame[False] 1232s 0.38s call tests/window/test_rolling_functions.py::test_rolling_functions_window_non_shrinkage[14] 1232s 0.27s call tests/window/test_apply.py::test_frame[False] 1232s 0.20s teardown tests/window/test_numba.py::TestEngine::test_dont_cache_args[False-True-True-table-expanding-window_kwargs1] 1232s 0.06s call tests/window/test_apply.py::test_nans[False] 1232s 0.06s teardown tests/window/test_win_type.py::test_rolling_center_axis_1 1232s 0.05s call tests/window/test_expanding.py::test_expanding_cov_pairwise 1232s 0.05s call tests/window/test_expanding.py::test_expanding_corr_pairwise 1232s 0.04s call tests/window/test_apply.py::test_center_reindex_frame[False] 1232s 0.03s call tests/window/test_apply.py::test_min_periods[False-None-0] 1232s 0.03s call tests/window/test_apply.py::test_center_reindex_series[False] 1232s 0.03s call tests/window/test_apply.py::test_min_periods[False-1-0] 1232s 0.03s call tests/window/test_apply.py::test_time_rule_series[False] 1232s 0.03s call tests/window/test_pairwise.py::test_rolling_pairwise_cov_corr[corr] 1232s 0.03s call tests/window/test_pairwise.py::test_rolling_pairwise_cov_corr[cov] 1232s 0.02s call tests/window/test_pairwise.py::TestPairwise::test_cov_mulittindex 1232s 0.02s call tests/window/test_pairwise.py::test_flex_binary_frame[corr] 1232s 0.02s call tests/window/test_ewm.py::test_ewm_pairwise_cov_corr[corr] 1232s 0.02s call tests/window/test_pairwise.py::test_flex_binary_frame[cov] 1232s 0.02s call tests/window/test_ewm.py::test_ewm_pairwise_cov_corr[cov] 1232s 0.02s call tests/window/test_expanding.py::test_expanding_cov_pairwise_diff_length 1232s 0.02s call tests/window/test_expanding.py::test_expanding_corr_pairwise_diff_length 1232s 0.02s call tests/window/test_apply.py::test_center[False] 1232s 0.02s call tests/window/test_apply.py::test_time_rule_frame[True] 1232s 0.02s call tests/window/test_apply.py::test_min_periods[False-2-0] 1232s 0.02s call tests/window/test_api.py::test_agg[None] 1232s 0.01s call tests/window/test_api.py::test_agg[2] 1232s 0.01s call tests/window/test_apply.py::test_rolling_apply_args_kwargs[args_kwargs1] 1232s 0.01s call tests/window/test_groupby.py::TestExpanding::test_expanding_corr_cov[corr] 1232s 0.01s call tests/window/test_groupby.py::TestExpanding::test_expanding_corr_cov[cov] 1232s == 9010 passed, 650 skipped, 536 deselected, 47 xfailed, 2 warnings in 27.73s == 1233s rdjoqkol test state = true 1233s + echo 'rdjoqkol test state = true' 1233s + true 1234s autopkgtest [17:44:14]: test unittests3: -----------------------] 1235s unittests3 PASS 1235s autopkgtest [17:44:15]: test unittests3: - - - - - - - - - - results - - - - - - - - - - 1235s autopkgtest [17:44:15]: test ignoredtests: preparing testbed 1235s Reading package lists... 1235s Building dependency tree... 1235s Reading state information... 1236s Starting pkgProblemResolver with broken count: 0 1236s Starting 2 pkgProblemResolver with broken count: 0 1236s Done 1237s The following NEW packages will be installed: 1237s libpq5 python3-psycopg2 python3-pymysql 1237s 0 upgraded, 3 newly installed, 0 to remove and 40 not upgraded. 1237s Need to get 315 kB of archives. 1237s After this operation, 1169 kB of additional disk space will be used. 1237s Get:1 http://ftpmaster.internal/ubuntu questing-proposed/main arm64 libpq5 arm64 17.4-2 [142 kB] 1237s Get:2 http://ftpmaster.internal/ubuntu questing/main arm64 python3-psycopg2 arm64 2.9.10-1build1 [133 kB] 1237s Get:3 http://ftpmaster.internal/ubuntu questing/main arm64 python3-pymysql all 1.1.1-2ubuntu1 [39.5 kB] 1238s Fetched 315 kB in 0s (632 kB/s) 1238s Selecting previously unselected package libpq5:arm64. 1238s (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 ... 141878 files and directories currently installed.) 1238s Preparing to unpack .../libpq5_17.4-2_arm64.deb ... 1238s Unpacking libpq5:arm64 (17.4-2) ... 1238s Selecting previously unselected package python3-psycopg2. 1238s Preparing to unpack .../python3-psycopg2_2.9.10-1build1_arm64.deb ... 1238s Unpacking python3-psycopg2 (2.9.10-1build1) ... 1238s Selecting previously unselected package python3-pymysql. 1238s Preparing to unpack .../python3-pymysql_1.1.1-2ubuntu1_all.deb ... 1238s Unpacking python3-pymysql (1.1.1-2ubuntu1) ... 1238s Setting up libpq5:arm64 (17.4-2) ... 1238s Setting up python3-psycopg2 (2.9.10-1build1) ... 1238s Setting up python3-pymysql (1.1.1-2ubuntu1) ... 1238s Processing triggers for libc-bin (2.41-6ubuntu1) ... 1239s autopkgtest [17:44:19]: test ignoredtests: [----------------------- 1239s === python3.13 === 1240s 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 1240s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1240s 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" 1240s 1240s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1242s ============================= test session starts ============================== 1242s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1242s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1242s rootdir: /usr/lib/python3/dist-packages/pandas/tests 1242s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 1242s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1242s collected 10446 items / 536 deselected / 2 skipped / 9910 selected 1242s 1245s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_ufunc.py ....xx.........xxxxxxxx.xx....s. 1246s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_timegrouper.py ..............................s 1247s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/transform/test_numba.py sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 1249s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_numba.py sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 1249s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_numba.py . 1279s ../../../usr/lib/python3/dist-packages/pandas/tests/window/moments/test_moments_consistency_ewm.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 1290s ../../../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................................................................................................................................................................................................................................................................................ 1311s ../../../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................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 1332s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_api.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1335s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_apply.py ...s....sssss..........s..s....................................................... 1341s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_base_indexer.py .................................................................................................................................................................................................................................... 1344s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_cython_aggregations.py ........................................................................ 1408s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_dtypes.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1416s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_ewm.py .......................................................................................................................................................................................................................................ssssssssssss........ssssssssssssssss................ 1425s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_expanding.py ..........x................................................................................................................................................................................................ss....s...................s..s......s............................................................................................. 1429s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_groupby.py ................................................................................................................... 1440s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 1451s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_pairwise.py ........................................................................................................................................................................................................................................................................................................................ 1485s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling.py .........................................................................................................................................................................................................................................................................................................................................................................................xxxx........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1500s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_functions.py .................................................................................................................................................................................................................................................................................................................................................................................................................................. 1506s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_quantile.py .......................................................................................................................................................................................... 1513s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_skew_kurt.py .................................................................... 1515s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_timeseries_window.py ..................................................................................s 1634s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_win_type.py ............................................................................................................................................................................................................................................................................................... 1634s 1634s =============================== warnings summary =============================== 1634s ../../../usr/lib/python3/dist-packages/pandas/compat/_optional.py:130 1634s ../../../usr/lib/python3/dist-packages/pandas/compat/_optional.py:130 1634s ../../../usr/lib/python3/dist-packages/pandas/compat/_optional.py:130 1634s ../../../usr/lib/python3/dist-packages/pandas/compat/_optional.py:130 1634s ../../../usr/lib/python3/dist-packages/pandas/compat/_optional.py:130 1634s /usr/lib/python3/dist-packages/pandas/compat/_optional.py:130: UserWarning: Non-x86 system detected, Numba may give wrong results or crash 1634s warnings.warn(warn_numba_platform) 1634s 1634s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_numba.py:11 1634s /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 1634s pytestmark = pytest.mark.single_cpu 1634s 1634s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_timegrouper.py:944 1634s /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 1634s @pytest.mark.single_cpu 1634s 1634s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/transform/test_numba.py:14 1634s /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 1634s pytestmark = pytest.mark.single_cpu 1634s 1634s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_numba.py:22 1634s /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 1634s pytestmark = pytest.mark.single_cpu 1634s 1634s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_numba.py:230 1634s /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 1634s @pytest.mark.single_cpu 1634s 1634s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py:21 1634s /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 1634s pytestmark = pytest.mark.single_cpu 1634s 1634s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py:326 1634s /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 1634s @pytest.mark.slow 1634s 1634s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_online.py:11 1634s /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 1634s pytestmark = pytest.mark.single_cpu 1634s 1634s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_skew_kurt.py:155 1634s /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 1634s @pytest.mark.slow 1634s 1634s frame/test_ufunc.py: 32 warnings 1634s groupby/test_timegrouper.py: 31 warnings 1634s groupby/transform/test_numba.py: 53 warnings 1634s groupby/aggregate/test_numba.py: 35 warnings 1634s util/test_numba.py: 1 warning 1634s window/moments/test_moments_consistency_ewm.py: 1088 warnings 1634s window/moments/test_moments_consistency_expanding.py: 380 warnings 1634s window/moments/test_moments_consistency_rolling.py: 760 warnings 1634s window/test_api.py: 937 warnings 1634s window/test_apply.py: 82 warnings 1634s window/test_base_indexer.py: 228 warnings 1634s window/test_cython_aggregations.py: 72 warnings 1634s window/test_dtypes.py: 2580 warnings 1634s window/test_ewm.py: 283 warnings 1634s window/test_expanding.py: 333 warnings 1634s window/test_groupby.py: 115 warnings 1634s window/test_numba.py: 51 warnings 1634s window/test_pairwise.py: 312 warnings 1634s window/test_rolling.py: 888 warnings 1634s window/test_rolling_functions.py: 418 warnings 1634s window/test_rolling_quantile.py: 186 warnings 1634s window/test_rolling_skew_kurt.py: 68 warnings 1634s window/test_timeseries_window.py: 83 warnings 1634s window/test_win_type.py: 287 warnings 1634s /usr/lib/python3/dist-packages/py/_process/forkedfunc.py:45: DeprecationWarning: This process (pid=7437) is multi-threaded, use of fork() may lead to deadlocks in the child. 1634s pid = os.fork() 1634s 1634s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1634s /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-t7hvkjph' 1634s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1634s 1634s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1634s /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-xrmr60n0' 1634s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1634s 1634s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1634s = 9060 passed, 793 skipped, 536 deselected, 59 xfailed, 9319 warnings in 393.26s (0:06:33) = 1635s various xfailed tests - see xfail_tests_nonintel_io.patch, ignore_test_1094417_1088988.patch 1636s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1636s 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" 1636s 1636s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1636s ============================= test session starts ============================== 1636s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1636s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1636s rootdir: /usr/lib/python3/dist-packages/pandas/tests 1636s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 1636s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1636s collected 366 items 1636s 1649s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py ...................................................FFFFFFFFF................................................................................................................................... 1652s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py ....F................ 1658s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py ............................................F..................... 1663s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py ....s..sssss.sF.........s. 1667s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py ..F.............FF..F.sFFFFFF................................. 1667s 1667s =================================== FAILURES =================================== 1667s ___________________________ test_complibs[blosc2-1] ____________________________ 1667s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-52/test_complibs_blosc2_1_0') 1667s lvl = 1, lib = 'blosc2' 1667s request = > 1667s 1667s @pytest.mark.parametrize("lvl", range(10)) 1667s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1667s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1667s @pytest.mark.skipif( 1667s not PY311 and is_ci_environment() and is_platform_linux(), 1667s reason="Segfaulting in a CI environment" 1667s # with xfail, would sometimes raise UnicodeDecodeError 1667s # invalid state byte 1667s ) 1667s def test_complibs(tmp_path, lvl, lib, request): 1667s # GH14478 1667s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1667s request.applymarker( 1667s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1667s ) 1667s df = DataFrame( 1667s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1667s ) 1667s 1667s # Remove lzo if its not available on this platform 1667s if not tables.which_lib_version("lzo"): 1667s pytest.skip("lzo not available") 1667s # Remove bzip2 if its not available on this platform 1667s if not tables.which_lib_version("bzip2"): 1667s pytest.skip("bzip2 not available") 1667s 1667s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1667s gname = f"{lvl}_{lib}" 1667s 1667s # Write and read file to see if data is consistent 1667s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1667s result = read_hdf(tmpfile, gname) 1667s tm.assert_frame_equal(result, df) 1667s 1667s # Open file and check metadata for correct amount of compression 1667s with tables.open_file(tmpfile, mode="r") as h5table: 1667s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1667s assert node.filters.complevel == lvl 1667s if lvl == 0: 1667s assert node.filters.complib is None 1667s else: 1667s > assert node.filters.complib == lib 1667s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1667s E 1667s E - blosc2 1667s E + blosc2:blosclz 1667s 1667s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1667s ___________________________ test_complibs[blosc2-2] ____________________________ 1667s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-53/test_complibs_blosc2_2_0') 1667s lvl = 2, lib = 'blosc2' 1667s request = > 1667s 1667s @pytest.mark.parametrize("lvl", range(10)) 1667s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1667s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1667s @pytest.mark.skipif( 1667s not PY311 and is_ci_environment() and is_platform_linux(), 1667s reason="Segfaulting in a CI environment" 1667s # with xfail, would sometimes raise UnicodeDecodeError 1667s # invalid state byte 1667s ) 1667s def test_complibs(tmp_path, lvl, lib, request): 1667s # GH14478 1667s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1667s request.applymarker( 1667s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1667s ) 1667s df = DataFrame( 1667s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1667s ) 1667s 1667s # Remove lzo if its not available on this platform 1667s if not tables.which_lib_version("lzo"): 1667s pytest.skip("lzo not available") 1667s # Remove bzip2 if its not available on this platform 1667s if not tables.which_lib_version("bzip2"): 1667s pytest.skip("bzip2 not available") 1667s 1667s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1667s gname = f"{lvl}_{lib}" 1667s 1667s # Write and read file to see if data is consistent 1667s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1667s result = read_hdf(tmpfile, gname) 1667s tm.assert_frame_equal(result, df) 1667s 1667s # Open file and check metadata for correct amount of compression 1667s with tables.open_file(tmpfile, mode="r") as h5table: 1667s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1667s assert node.filters.complevel == lvl 1667s if lvl == 0: 1667s assert node.filters.complib is None 1667s else: 1667s > assert node.filters.complib == lib 1667s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1667s E 1667s E - blosc2 1667s E + blosc2:blosclz 1667s 1667s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1667s ___________________________ test_complibs[blosc2-3] ____________________________ 1667s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-54/test_complibs_blosc2_3_0') 1667s lvl = 3, lib = 'blosc2' 1667s request = > 1667s 1667s @pytest.mark.parametrize("lvl", range(10)) 1667s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1667s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1667s @pytest.mark.skipif( 1667s not PY311 and is_ci_environment() and is_platform_linux(), 1667s reason="Segfaulting in a CI environment" 1667s # with xfail, would sometimes raise UnicodeDecodeError 1667s # invalid state byte 1667s ) 1667s def test_complibs(tmp_path, lvl, lib, request): 1667s # GH14478 1667s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1667s request.applymarker( 1667s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1667s ) 1667s df = DataFrame( 1667s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1667s ) 1667s 1667s # Remove lzo if its not available on this platform 1667s if not tables.which_lib_version("lzo"): 1667s pytest.skip("lzo not available") 1667s # Remove bzip2 if its not available on this platform 1667s if not tables.which_lib_version("bzip2"): 1667s pytest.skip("bzip2 not available") 1667s 1667s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1667s gname = f"{lvl}_{lib}" 1667s 1667s # Write and read file to see if data is consistent 1667s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1667s result = read_hdf(tmpfile, gname) 1667s tm.assert_frame_equal(result, df) 1667s 1667s # Open file and check metadata for correct amount of compression 1667s with tables.open_file(tmpfile, mode="r") as h5table: 1667s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1667s assert node.filters.complevel == lvl 1667s if lvl == 0: 1667s assert node.filters.complib is None 1667s else: 1667s > assert node.filters.complib == lib 1667s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1667s E 1667s E - blosc2 1667s E + blosc2:blosclz 1667s 1667s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1667s ___________________________ test_complibs[blosc2-4] ____________________________ 1667s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-55/test_complibs_blosc2_4_0') 1667s lvl = 4, lib = 'blosc2' 1667s request = > 1667s 1667s @pytest.mark.parametrize("lvl", range(10)) 1667s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1667s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1667s @pytest.mark.skipif( 1667s not PY311 and is_ci_environment() and is_platform_linux(), 1667s reason="Segfaulting in a CI environment" 1667s # with xfail, would sometimes raise UnicodeDecodeError 1667s # invalid state byte 1667s ) 1667s def test_complibs(tmp_path, lvl, lib, request): 1667s # GH14478 1667s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1667s request.applymarker( 1667s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1667s ) 1667s df = DataFrame( 1667s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1667s ) 1667s 1667s # Remove lzo if its not available on this platform 1667s if not tables.which_lib_version("lzo"): 1667s pytest.skip("lzo not available") 1667s # Remove bzip2 if its not available on this platform 1667s if not tables.which_lib_version("bzip2"): 1667s pytest.skip("bzip2 not available") 1667s 1667s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1667s gname = f"{lvl}_{lib}" 1667s 1667s # Write and read file to see if data is consistent 1667s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1667s result = read_hdf(tmpfile, gname) 1667s tm.assert_frame_equal(result, df) 1667s 1667s # Open file and check metadata for correct amount of compression 1667s with tables.open_file(tmpfile, mode="r") as h5table: 1667s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1667s assert node.filters.complevel == lvl 1667s if lvl == 0: 1667s assert node.filters.complib is None 1667s else: 1667s > assert node.filters.complib == lib 1667s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1667s E 1667s E - blosc2 1667s E + blosc2:blosclz 1667s 1667s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1667s ___________________________ test_complibs[blosc2-5] ____________________________ 1667s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-56/test_complibs_blosc2_5_0') 1667s lvl = 5, lib = 'blosc2' 1667s request = > 1667s 1667s @pytest.mark.parametrize("lvl", range(10)) 1667s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1667s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1667s @pytest.mark.skipif( 1667s not PY311 and is_ci_environment() and is_platform_linux(), 1667s reason="Segfaulting in a CI environment" 1667s # with xfail, would sometimes raise UnicodeDecodeError 1667s # invalid state byte 1667s ) 1667s def test_complibs(tmp_path, lvl, lib, request): 1667s # GH14478 1667s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1667s request.applymarker( 1667s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1667s ) 1667s df = DataFrame( 1667s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1667s ) 1667s 1667s # Remove lzo if its not available on this platform 1667s if not tables.which_lib_version("lzo"): 1667s pytest.skip("lzo not available") 1667s # Remove bzip2 if its not available on this platform 1667s if not tables.which_lib_version("bzip2"): 1667s pytest.skip("bzip2 not available") 1667s 1667s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1667s gname = f"{lvl}_{lib}" 1667s 1667s # Write and read file to see if data is consistent 1667s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1667s result = read_hdf(tmpfile, gname) 1667s tm.assert_frame_equal(result, df) 1667s 1667s # Open file and check metadata for correct amount of compression 1667s with tables.open_file(tmpfile, mode="r") as h5table: 1667s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1667s assert node.filters.complevel == lvl 1667s if lvl == 0: 1667s assert node.filters.complib is None 1667s else: 1667s > assert node.filters.complib == lib 1667s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1667s E 1667s E - blosc2 1667s E + blosc2:blosclz 1667s 1667s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1667s ___________________________ test_complibs[blosc2-6] ____________________________ 1667s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-57/test_complibs_blosc2_6_0') 1667s lvl = 6, lib = 'blosc2' 1667s request = > 1667s 1667s @pytest.mark.parametrize("lvl", range(10)) 1667s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1667s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1667s @pytest.mark.skipif( 1667s not PY311 and is_ci_environment() and is_platform_linux(), 1667s reason="Segfaulting in a CI environment" 1667s # with xfail, would sometimes raise UnicodeDecodeError 1667s # invalid state byte 1667s ) 1667s def test_complibs(tmp_path, lvl, lib, request): 1667s # GH14478 1667s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1667s request.applymarker( 1667s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1667s ) 1667s df = DataFrame( 1667s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1667s ) 1667s 1667s # Remove lzo if its not available on this platform 1667s if not tables.which_lib_version("lzo"): 1667s pytest.skip("lzo not available") 1667s # Remove bzip2 if its not available on this platform 1667s if not tables.which_lib_version("bzip2"): 1667s pytest.skip("bzip2 not available") 1667s 1667s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1667s gname = f"{lvl}_{lib}" 1667s 1667s # Write and read file to see if data is consistent 1667s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1667s result = read_hdf(tmpfile, gname) 1667s tm.assert_frame_equal(result, df) 1667s 1667s # Open file and check metadata for correct amount of compression 1667s with tables.open_file(tmpfile, mode="r") as h5table: 1667s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1667s assert node.filters.complevel == lvl 1667s if lvl == 0: 1667s assert node.filters.complib is None 1667s else: 1667s > assert node.filters.complib == lib 1667s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1667s E 1667s E - blosc2 1667s E + blosc2:blosclz 1667s 1667s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1667s ___________________________ test_complibs[blosc2-7] ____________________________ 1667s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-58/test_complibs_blosc2_7_0') 1667s lvl = 7, lib = 'blosc2' 1667s request = > 1667s 1667s @pytest.mark.parametrize("lvl", range(10)) 1667s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1667s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1667s @pytest.mark.skipif( 1667s not PY311 and is_ci_environment() and is_platform_linux(), 1667s reason="Segfaulting in a CI environment" 1667s # with xfail, would sometimes raise UnicodeDecodeError 1667s # invalid state byte 1667s ) 1667s def test_complibs(tmp_path, lvl, lib, request): 1667s # GH14478 1667s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1667s request.applymarker( 1667s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1667s ) 1667s df = DataFrame( 1667s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1667s ) 1667s 1667s # Remove lzo if its not available on this platform 1667s if not tables.which_lib_version("lzo"): 1667s pytest.skip("lzo not available") 1667s # Remove bzip2 if its not available on this platform 1667s if not tables.which_lib_version("bzip2"): 1667s pytest.skip("bzip2 not available") 1667s 1667s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1667s gname = f"{lvl}_{lib}" 1667s 1667s # Write and read file to see if data is consistent 1667s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1667s result = read_hdf(tmpfile, gname) 1667s tm.assert_frame_equal(result, df) 1667s 1667s # Open file and check metadata for correct amount of compression 1667s with tables.open_file(tmpfile, mode="r") as h5table: 1667s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1667s assert node.filters.complevel == lvl 1667s if lvl == 0: 1667s assert node.filters.complib is None 1667s else: 1667s > assert node.filters.complib == lib 1667s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1667s E 1667s E - blosc2 1667s E + blosc2:blosclz 1667s 1667s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1667s ___________________________ test_complibs[blosc2-8] ____________________________ 1667s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-59/test_complibs_blosc2_8_0') 1667s lvl = 8, lib = 'blosc2' 1667s request = > 1667s 1667s @pytest.mark.parametrize("lvl", range(10)) 1667s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1667s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1667s @pytest.mark.skipif( 1667s not PY311 and is_ci_environment() and is_platform_linux(), 1667s reason="Segfaulting in a CI environment" 1667s # with xfail, would sometimes raise UnicodeDecodeError 1667s # invalid state byte 1667s ) 1667s def test_complibs(tmp_path, lvl, lib, request): 1667s # GH14478 1667s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1667s request.applymarker( 1667s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1667s ) 1667s df = DataFrame( 1667s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1667s ) 1667s 1667s # Remove lzo if its not available on this platform 1667s if not tables.which_lib_version("lzo"): 1667s pytest.skip("lzo not available") 1667s # Remove bzip2 if its not available on this platform 1667s if not tables.which_lib_version("bzip2"): 1667s pytest.skip("bzip2 not available") 1667s 1667s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1667s gname = f"{lvl}_{lib}" 1667s 1667s # Write and read file to see if data is consistent 1667s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1667s result = read_hdf(tmpfile, gname) 1667s tm.assert_frame_equal(result, df) 1667s 1667s # Open file and check metadata for correct amount of compression 1667s with tables.open_file(tmpfile, mode="r") as h5table: 1667s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1667s assert node.filters.complevel == lvl 1667s if lvl == 0: 1667s assert node.filters.complib is None 1667s else: 1667s > assert node.filters.complib == lib 1667s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1667s E 1667s E - blosc2 1667s E + blosc2:blosclz 1667s 1667s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1667s ___________________________ test_complibs[blosc2-9] ____________________________ 1667s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-60/test_complibs_blosc2_9_0') 1667s lvl = 9, lib = 'blosc2' 1667s request = > 1667s 1667s @pytest.mark.parametrize("lvl", range(10)) 1667s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1667s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1667s @pytest.mark.skipif( 1667s not PY311 and is_ci_environment() and is_platform_linux(), 1667s reason="Segfaulting in a CI environment" 1667s # with xfail, would sometimes raise UnicodeDecodeError 1667s # invalid state byte 1667s ) 1667s def test_complibs(tmp_path, lvl, lib, request): 1667s # GH14478 1667s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1667s request.applymarker( 1667s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1667s ) 1667s df = DataFrame( 1667s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1667s ) 1667s 1667s # Remove lzo if its not available on this platform 1667s if not tables.which_lib_version("lzo"): 1667s pytest.skip("lzo not available") 1667s # Remove bzip2 if its not available on this platform 1667s if not tables.which_lib_version("bzip2"): 1667s pytest.skip("bzip2 not available") 1667s 1667s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1667s gname = f"{lvl}_{lib}" 1667s 1667s # Write and read file to see if data is consistent 1667s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1667s result = read_hdf(tmpfile, gname) 1667s tm.assert_frame_equal(result, df) 1667s 1667s # Open file and check metadata for correct amount of compression 1667s with tables.open_file(tmpfile, mode="r") as h5table: 1667s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1667s assert node.filters.complevel == lvl 1667s if lvl == 0: 1667s assert node.filters.complib is None 1667s else: 1667s > assert node.filters.complib == lib 1667s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1667s E 1667s E - blosc2 1667s E + blosc2:blosclz 1667s 1667s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1667s ______________________ test_append_frame_column_oriented _______________________ 1667s self = 1667s node = , kwargs = {'side': 'right'} 1667s value = 1667s slobj = slice(0, 4, None) 1667s 1667s def visit_Subscript(self, node, **kwargs) -> ops.Term: 1667s # only allow simple subscripts 1667s 1667s value = self.visit(node.value) 1667s slobj = self.visit(node.slice) 1667s try: 1667s value = value.value 1667s except AttributeError: 1667s pass 1667s 1667s if isinstance(slobj, Term): 1667s # In py39 np.ndarray lookups with Term containing int raise 1667s slobj = slobj.value 1667s 1667s try: 1667s > return self.const_type(value[slobj], self.env) 1667s E TypeError: 'builtin_function_or_method' object is not subscriptable 1667s 1667s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:468: TypeError 1667s 1667s The above exception was the direct cause of the following exception: 1667s 1667s setup_path = 'tmp.__2ab0bdc8-b2da-4a5a-a3ee-cb8806de3239__.h5' 1667s 1667s @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) 1667s def test_append_frame_column_oriented(setup_path): 1667s with ensure_clean_store(setup_path) as store: 1667s # column oriented 1667s df = DataFrame( 1667s np.random.default_rng(2).standard_normal((10, 4)), 1667s columns=Index(list("ABCD"), dtype=object), 1667s index=date_range("2000-01-01", periods=10, freq="B"), 1667s ) 1667s df.index = df.index._with_freq(None) # freq doesn't round-trip 1667s 1667s _maybe_remove(store, "df1") 1667s store.append("df1", df.iloc[:, :2], axes=["columns"]) 1667s store.append("df1", df.iloc[:, 2:]) 1667s tm.assert_frame_equal(store["df1"], df) 1667s 1667s result = store.select("df1", "columns=A") 1667s expected = df.reindex(columns=["A"]) 1667s tm.assert_frame_equal(expected, result) 1667s 1667s # selection on the non-indexable 1667s > result = store.select("df1", ("columns=A", "index=df.index[0:4]")) 1667s 1667s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py:311: 1667s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1667s /usr/lib/python3/dist-packages/pandas/io/pytables.py:915: in select 1667s return it.get_result() 1667s /usr/lib/python3/dist-packages/pandas/io/pytables.py:2038: in get_result 1667s results = self.func(self.start, self.stop, where) 1667s /usr/lib/python3/dist-packages/pandas/io/pytables.py:899: in func 1667s return s.read(start=_start, stop=_stop, where=_where, columns=columns) 1667s /usr/lib/python3/dist-packages/pandas/io/pytables.py:4640: in read 1667s result = self._read_axes(where=where, start=start, stop=stop) 1667s /usr/lib/python3/dist-packages/pandas/io/pytables.py:3826: in _read_axes 1667s selection = Selection(self, where=where, start=start, stop=stop) 1667s /usr/lib/python3/dist-packages/pandas/io/pytables.py:5367: in __init__ 1667s self.terms = self.generate(where) 1667s /usr/lib/python3/dist-packages/pandas/io/pytables.py:5380: in generate 1667s return PyTablesExpr(where, queryables=q, encoding=self.table.encoding) 1667s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:610: in __init__ 1667s self.terms = self.parse() 1667s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:824: in parse 1667s return self._visitor.visit(self.expr) 1667s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1667s return visitor(node, **kwargs) 1667s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:417: in visit_Module 1667s return self.visit(expr, **kwargs) 1667s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1667s return visitor(node, **kwargs) 1667s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:420: in visit_Expr 1667s return self.visit(node.value, **kwargs) 1667s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1667s return visitor(node, **kwargs) 1667s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:742: in visit_BoolOp 1667s return reduce(visitor, operands) 1667s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:736: in visitor 1667s rhs = self._try_visit_binop(y) 1667s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:731: in _try_visit_binop 1667s return self.visit(bop) 1667s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1667s return visitor(node, **kwargs) 1667s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:715: in visit_Compare 1667s return self.visit(binop) 1667s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1667s return visitor(node, **kwargs) 1667s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:531: in visit_BinOp 1667s op, op_class, left, right = self._maybe_transform_eq_ne(node) 1667s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:453: in _maybe_transform_eq_ne 1667s right = self.visit(node.right, side="right") 1667s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1667s return visitor(node, **kwargs) 1667s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1667s 1667s self = 1667s node = , kwargs = {'side': 'right'} 1667s value = 1667s slobj = slice(0, 4, None) 1667s 1667s def visit_Subscript(self, node, **kwargs) -> ops.Term: 1667s # only allow simple subscripts 1667s 1667s value = self.visit(node.value) 1667s slobj = self.visit(node.slice) 1667s try: 1667s value = value.value 1667s except AttributeError: 1667s pass 1667s 1667s if isinstance(slobj, Term): 1667s # In py39 np.ndarray lookups with Term containing int raise 1667s slobj = slobj.value 1667s 1667s try: 1667s return self.const_type(value[slobj], self.env) 1667s except TypeError as err: 1667s > raise ValueError( 1667s f"cannot subscript {repr(value)} with {repr(slobj)}" 1667s ) from err 1667s E ValueError: cannot subscript with slice(0, 4, None) 1667s 1667s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:470: ValueError 1667s __________________________ test_select_filter_corner ___________________________ 1667s setup_path = 'tmp.__b08b183b-8e81-43f8-b92d-14af4cf49b51__.h5' 1667s 1667s @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) 1667s def test_select_filter_corner(setup_path): 1667s df = DataFrame(np.random.default_rng(2).standard_normal((50, 100))) 1667s df.index = [f"{c:3d}" for c in df.index] 1667s df.columns = [f"{c:3d}" for c in df.columns] 1667s 1667s with ensure_clean_store(setup_path) as store: 1667s store.put("frame", df, format="table") 1667s 1667s crit = "columns=df.columns[:75]" 1667s > result = store.select("frame", [crit]) 1667s 1667s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py:899: 1667s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1667s /usr/lib/python3/dist-packages/pandas/io/pytables.py:915: in select 1667s return it.get_result() 1667s /usr/lib/python3/dist-packages/pandas/io/pytables.py:2038: in get_result 1667s results = self.func(self.start, self.stop, where) 1667s /usr/lib/python3/dist-packages/pandas/io/pytables.py:899: in func 1667s return s.read(start=_start, stop=_stop, where=_where, columns=columns) 1667s /usr/lib/python3/dist-packages/pandas/io/pytables.py:4640: in read 1667s result = self._read_axes(where=where, start=start, stop=stop) 1667s /usr/lib/python3/dist-packages/pandas/io/pytables.py:3826: in _read_axes 1667s selection = Selection(self, where=where, start=start, stop=stop) 1667s /usr/lib/python3/dist-packages/pandas/io/pytables.py:5367: in __init__ 1667s self.terms = self.generate(where) 1667s /usr/lib/python3/dist-packages/pandas/io/pytables.py:5380: in generate 1667s return PyTablesExpr(where, queryables=q, encoding=self.table.encoding) 1667s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:610: in __init__ 1667s self.terms = self.parse() 1667s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:824: in parse 1667s return self._visitor.visit(self.expr) 1667s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1667s return visitor(node, **kwargs) 1667s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:417: in visit_Module 1667s return self.visit(expr, **kwargs) 1667s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1667s return visitor(node, **kwargs) 1667s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:420: in visit_Expr 1667s return self.visit(node.value, **kwargs) 1667s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1667s return visitor(node, **kwargs) 1667s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:715: in visit_Compare 1667s return self.visit(binop) 1667s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1667s return visitor(node, **kwargs) 1667s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:531: in visit_BinOp 1667s op, op_class, left, right = self._maybe_transform_eq_ne(node) 1667s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:453: in _maybe_transform_eq_ne 1667s right = self.visit(node.right, side="right") 1667s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1667s return visitor(node, **kwargs) 1667s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:456: in visit_Subscript 1667s value = self.visit(node.value) 1667s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1667s return visitor(node, **kwargs) 1667s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1667s 1667s self = 1667s node = , kwargs = {}, attr = 'columns' 1667s value = , ctx = 1667s resolved = 'df' 1667s 1667s def visit_Attribute(self, node, **kwargs): 1667s attr = node.attr 1667s value = node.value 1667s 1667s ctx = type(node.ctx) 1667s if ctx == ast.Load: 1667s # resolve the value 1667s resolved = self.visit(value) 1667s 1667s # try to get the value to see if we are another expression 1667s try: 1667s resolved = resolved.value 1667s except AttributeError: 1667s pass 1667s 1667s try: 1667s return self.term_type(getattr(resolved, attr), self.env) 1667s except AttributeError: 1667s # something like datetime.datetime where scope is overridden 1667s if isinstance(value, ast.Name) and value.id == attr: 1667s return resolved 1667s 1667s > raise ValueError(f"Invalid Attribute context {ctx.__name__}") 1667s E ValueError: Invalid Attribute context Load 1667s 1667s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:496: ValueError 1667s __________________ test_frame_setitem_dask_array_into_new_col __________________ 1667s @pytest.mark.xfail( 1667s condition=True,#not IS64, 1667s reason="ignoring https://bugs.debian.org/1094417 to unblock transition",#"dask has different nativesize-int vs int64 type rules", 1667s strict=False, 1667s ) 1667s def test_frame_setitem_dask_array_into_new_col(): 1667s # GH#47128 1667s 1667s # dask sets "compute.use_numexpr" to False, so catch the current value 1667s # and ensure to reset it afterwards to avoid impacting other tests 1667s olduse = pd.get_option("compute.use_numexpr") 1667s 1667s try: 1667s da = td.versioned_importorskip("dask.array") 1667s 1667s dda = da.array([1, 2]) 1667s df = DataFrame({"a": ["a", "b"]}) 1667s df["b"] = dda 1667s df["c"] = dda 1667s df.loc[[False, True], "b"] = 100 1667s result = df.loc[[1], :] 1667s expected = DataFrame({"a": ["b"], "b": [100], "c": [2]}, index=[1]) 1667s > tm.assert_frame_equal(result, expected) 1667s 1667s /usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:256: 1667s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1667s 1667s left = array([100]), right = array([2]), err_msg = None 1667s 1667s def _raise(left, right, err_msg) -> NoReturn: 1667s if err_msg is None: 1667s if left.shape != right.shape: 1667s raise_assert_detail( 1667s obj, f"{obj} shapes are different", left.shape, right.shape 1667s ) 1667s 1667s diff = 0 1667s for left_arr, right_arr in zip(left, right): 1667s # count up differences 1667s if not array_equivalent(left_arr, right_arr, strict_nan=strict_nan): 1667s diff += 1 1667s 1667s diff = diff * 100.0 / left.size 1667s msg = f"{obj} values are different ({np.round(diff, 5)} %)" 1667s > raise_assert_detail(obj, msg, left, right, index_values=index_values) 1667s E AssertionError: DataFrame.iloc[:, 2] (column name="c") are different 1667s E 1667s E DataFrame.iloc[:, 2] (column name="c") values are different (100.0 %) 1667s E [index]: [1] 1667s E [left]: [100] 1667s E [right]: [2] 1667s 1667s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:684: AssertionError 1667s ________ TestDataFrameToXArray.test_to_xarray_index_types[datetime-tz] _________ 1667s self = 1667s index_flat = DatetimeIndex(['2020-01-01 00:00:00-08:00', '2020-01-02 00:00:00-08:00', 1667s '2020-01-03 00:00:00-08:00', '... '2020-04-08 00:00:00-07:00', '2020-04-09 00:00:00-07:00'], 1667s dtype='datetime64[ns, US/Pacific]', freq='D') 1667s df = bar a b c ... f g h 1667s foo .....03 00:00:00-05:00 1667s 2020-01-04 00:00:00-08:00 d 4 6 ... d 2013-01-04 2013-01-04 00:00:00-05:00 1667s 1667s [4 rows x 8 columns] 1667s using_infer_string = False 1667s 1667s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1667s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1667s index = index_flat 1667s # MultiIndex is tested in test_to_xarray_with_multiindex 1667s if len(index) == 0: 1667s pytest.skip("Test doesn't make sense for empty index") 1667s 1667s from xarray import Dataset 1667s 1667s df.index = index[:4] 1667s df.index.name = "foo" 1667s df.columns.name = "bar" 1667s result = df.to_xarray() 1667s assert result.sizes["foo"] == 4 1667s assert len(result.coords) == 1 1667s assert len(result.data_vars) == 8 1667s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1667s assert isinstance(result, Dataset) 1667s 1667s # idempotency 1667s # datetimes w/tz are preserved 1667s # column names are lost 1667s expected = df.copy() 1667s # breaks in xarray >= 2024.10.0(?) 1667s # debug print 1667s r0 = result.to_dataframe() 1667s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1667s expected.columns.name = None 1667s > tm.assert_frame_equal(result.to_dataframe(), expected) 1667s 1667s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1667s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1667s 1667s left = Index([2020-01-01 00:00:00-08:00, 2020-01-02 00:00:00-08:00, 1667s 2020-01-03 00:00:00-08:00, 2020-01-04 00:00:00-08:00], 1667s dtype='object', name='foo') 1667s right = DatetimeIndex(['2020-01-01 00:00:00-08:00', '2020-01-02 00:00:00-08:00', 1667s '2020-01-03 00:00:00-08:00', '2020-01-04 00:00:00-08:00'], 1667s dtype='datetime64[ns, US/Pacific]', name='foo', freq='D') 1667s obj = 'DataFrame.index' 1667s 1667s def _check_types(left, right, obj: str = "Index") -> None: 1667s if not exact: 1667s return 1667s 1667s > assert_class_equal(left, right, exact=exact, obj=obj) 1667s E AssertionError: DataFrame.index are different 1667s E 1667s E DataFrame.index classes are different 1667s E [left]: Index([2020-01-01 00:00:00-08:00, 2020-01-02 00:00:00-08:00, 1667s E 2020-01-03 00:00:00-08:00, 2020-01-04 00:00:00-08:00], 1667s E dtype='object', name='foo') 1667s E [right]: DatetimeIndex(['2020-01-01 00:00:00-08:00', '2020-01-02 00:00:00-08:00', 1667s E '2020-01-03 00:00:00-08:00', '2020-01-04 00:00:00-08:00'], 1667s E dtype='datetime64[ns, US/Pacific]', name='foo', freq='D') 1667s 1667s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:235: AssertionError 1667s ________ TestDataFrameToXArray.test_to_xarray_index_types[bool-object] _________ 1667s self = 1667s index_flat = Index([True, False, True, False, True, False, True, False, True, False], dtype='object') 1667s df = bar a b c d e f g h 1667s foo ... 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1667s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1667s using_infer_string = False 1667s 1667s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1667s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1667s index = index_flat 1667s # MultiIndex is tested in test_to_xarray_with_multiindex 1667s if len(index) == 0: 1667s pytest.skip("Test doesn't make sense for empty index") 1667s 1667s from xarray import Dataset 1667s 1667s df.index = index[:4] 1667s df.index.name = "foo" 1667s df.columns.name = "bar" 1667s result = df.to_xarray() 1667s assert result.sizes["foo"] == 4 1667s assert len(result.coords) == 1 1667s assert len(result.data_vars) == 8 1667s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1667s assert isinstance(result, Dataset) 1667s 1667s # idempotency 1667s # datetimes w/tz are preserved 1667s # column names are lost 1667s expected = df.copy() 1667s # breaks in xarray >= 2024.10.0(?) 1667s # debug print 1667s r0 = result.to_dataframe() 1667s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1667s expected.columns.name = None 1667s > tm.assert_frame_equal(result.to_dataframe(), expected) 1667s E AssertionError: DataFrame are different 1667s E 1667s E DataFrame shape mismatch 1667s E [left]: (8, 8) 1667s E [right]: (4, 8) 1667s 1667s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: AssertionError 1667s _________ TestDataFrameToXArray.test_to_xarray_index_types[bool-dtype] _________ 1667s self = 1667s index_flat = Index([True, False, True, False, True, False, True, False, True, False], dtype='bool') 1667s df = bar a b c d e f g h 1667s foo ... 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1667s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1667s using_infer_string = False 1667s 1667s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1667s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1667s index = index_flat 1667s # MultiIndex is tested in test_to_xarray_with_multiindex 1667s if len(index) == 0: 1667s pytest.skip("Test doesn't make sense for empty index") 1667s 1667s from xarray import Dataset 1667s 1667s df.index = index[:4] 1667s df.index.name = "foo" 1667s df.columns.name = "bar" 1667s result = df.to_xarray() 1667s assert result.sizes["foo"] == 4 1667s assert len(result.coords) == 1 1667s assert len(result.data_vars) == 8 1667s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1667s assert isinstance(result, Dataset) 1667s 1667s # idempotency 1667s # datetimes w/tz are preserved 1667s # column names are lost 1667s expected = df.copy() 1667s # breaks in xarray >= 2024.10.0(?) 1667s # debug print 1667s r0 = result.to_dataframe() 1667s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1667s expected.columns.name = None 1667s > tm.assert_frame_equal(result.to_dataframe(), expected) 1667s E AssertionError: DataFrame are different 1667s E 1667s E DataFrame shape mismatch 1667s E [left]: (8, 8) 1667s E [right]: (4, 8) 1667s 1667s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: AssertionError 1667s ________ TestDataFrameToXArray.test_to_xarray_index_types[categorical] _________ 1667s self = 1667s index_flat = CategoricalIndex(['a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 1667s 'a', 'b', 'c', 'd', 'a... 'a', 'b', 'c', 'd'], 1667s categories=['a', 'b', 'c', 'd'], ordered=False, dtype='category') 1667s df = bar a b c d e f g h 1667s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1667s d d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1667s using_infer_string = False 1667s 1667s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1667s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1667s index = index_flat 1667s # MultiIndex is tested in test_to_xarray_with_multiindex 1667s if len(index) == 0: 1667s pytest.skip("Test doesn't make sense for empty index") 1667s 1667s from xarray import Dataset 1667s 1667s df.index = index[:4] 1667s df.index.name = "foo" 1667s df.columns.name = "bar" 1667s result = df.to_xarray() 1667s assert result.sizes["foo"] == 4 1667s assert len(result.coords) == 1 1667s assert len(result.data_vars) == 8 1667s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1667s assert isinstance(result, Dataset) 1667s 1667s # idempotency 1667s # datetimes w/tz are preserved 1667s # column names are lost 1667s expected = df.copy() 1667s # breaks in xarray >= 2024.10.0(?) 1667s # debug print 1667s r0 = result.to_dataframe() 1667s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1667s expected.columns.name = None 1667s > tm.assert_frame_equal(result.to_dataframe(), expected) 1667s 1667s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1667s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1667s 1667s left = Index(['a', 'b', 'c', 'd'], dtype='object', name='foo') 1667s right = CategoricalIndex(['a', 'b', 'c', 'd'], categories=['a', 'b', 'c', 'd'], ordered=False, dtype='category', name='foo') 1667s obj = 'DataFrame.index' 1667s 1667s def _check_types(left, right, obj: str = "Index") -> None: 1667s if not exact: 1667s return 1667s 1667s > assert_class_equal(left, right, exact=exact, obj=obj) 1667s E AssertionError: DataFrame.index are different 1667s E 1667s E DataFrame.index classes are different 1667s E [left]: Index(['a', 'b', 'c', 'd'], dtype='object', name='foo') 1667s E [right]: CategoricalIndex(['a', 'b', 'c', 'd'], categories=['a', 'b', 'c', 'd'], ordered=False, dtype='category', name='foo') 1667s 1667s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:235: AssertionError 1667s __________ TestDataFrameToXArray.test_to_xarray_index_types[repeats] ___________ 1667s self = 1667s index_flat = Index([0, 0, 1, 1, 2, 2], dtype='int64') 1667s df = bar a b c d e f g h 1667s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1667s 1 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1667s using_infer_string = False 1667s 1667s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1667s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1667s index = index_flat 1667s # MultiIndex is tested in test_to_xarray_with_multiindex 1667s if len(index) == 0: 1667s pytest.skip("Test doesn't make sense for empty index") 1667s 1667s from xarray import Dataset 1667s 1667s df.index = index[:4] 1667s df.index.name = "foo" 1667s df.columns.name = "bar" 1667s result = df.to_xarray() 1667s assert result.sizes["foo"] == 4 1667s assert len(result.coords) == 1 1667s assert len(result.data_vars) == 8 1667s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1667s assert isinstance(result, Dataset) 1667s 1667s # idempotency 1667s # datetimes w/tz are preserved 1667s # column names are lost 1667s expected = df.copy() 1667s # breaks in xarray >= 2024.10.0(?) 1667s # debug print 1667s r0 = result.to_dataframe() 1667s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1667s expected.columns.name = None 1667s > tm.assert_frame_equal(result.to_dataframe(), expected) 1667s E AssertionError: DataFrame are different 1667s E 1667s E DataFrame shape mismatch 1667s E [left]: (8, 8) 1667s E [right]: (4, 8) 1667s 1667s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: AssertionError 1667s ________ TestDataFrameToXArray.test_to_xarray_index_types[nullable_int] ________ 1667s self = 1667s index_flat = Index([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 1667s 18, 19, 20, 21, 22, 23, 24, 25, ...7, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 1667s 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 1667s dtype='Int64') 1667s df = bar a b c d e f g h 1667s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1667s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1667s using_infer_string = False 1667s 1667s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1667s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1667s index = index_flat 1667s # MultiIndex is tested in test_to_xarray_with_multiindex 1667s if len(index) == 0: 1667s pytest.skip("Test doesn't make sense for empty index") 1667s 1667s from xarray import Dataset 1667s 1667s df.index = index[:4] 1667s df.index.name = "foo" 1667s df.columns.name = "bar" 1667s result = df.to_xarray() 1667s assert result.sizes["foo"] == 4 1667s assert len(result.coords) == 1 1667s assert len(result.data_vars) == 8 1667s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1667s assert isinstance(result, Dataset) 1667s 1667s # idempotency 1667s # datetimes w/tz are preserved 1667s # column names are lost 1667s expected = df.copy() 1667s # breaks in xarray >= 2024.10.0(?) 1667s # debug print 1667s r0 = result.to_dataframe() 1667s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1667s expected.columns.name = None 1667s > tm.assert_frame_equal(result.to_dataframe(), expected) 1667s 1667s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1667s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1667s 1667s left = Index([0, 1, 2, 3], dtype='object', name='foo') 1667s right = Index([0, 1, 2, 3], dtype='Int64', name='foo'), obj = 'DataFrame.index' 1667s 1667s def _check_types(left, right, obj: str = "Index") -> None: 1667s if not exact: 1667s return 1667s 1667s assert_class_equal(left, right, exact=exact, obj=obj) 1667s assert_attr_equal("inferred_type", left, right, obj=obj) 1667s 1667s # Skip exact dtype checking when `check_categorical` is False 1667s if isinstance(left.dtype, CategoricalDtype) and isinstance( 1667s right.dtype, CategoricalDtype 1667s ): 1667s if check_categorical: 1667s assert_attr_equal("dtype", left, right, obj=obj) 1667s assert_index_equal(left.categories, right.categories, exact=exact) 1667s return 1667s 1667s > assert_attr_equal("dtype", left, right, obj=obj) 1667s E AssertionError: DataFrame.index are different 1667s E 1667s E Attribute "dtype" are different 1667s E [left]: object 1667s E [right]: Int64 1667s 1667s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:247: AssertionError 1667s _______ TestDataFrameToXArray.test_to_xarray_index_types[nullable_uint] ________ 1667s self = 1667s index_flat = Index([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 1667s 18, 19, 20, 21, 22, 23, 24, 25, ..., 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 1667s 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 1667s dtype='UInt16') 1667s df = bar a b c d e f g h 1667s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1667s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1667s using_infer_string = False 1667s 1667s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1667s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1667s index = index_flat 1667s # MultiIndex is tested in test_to_xarray_with_multiindex 1667s if len(index) == 0: 1667s pytest.skip("Test doesn't make sense for empty index") 1667s 1667s from xarray import Dataset 1667s 1667s df.index = index[:4] 1667s df.index.name = "foo" 1667s df.columns.name = "bar" 1667s result = df.to_xarray() 1667s assert result.sizes["foo"] == 4 1667s assert len(result.coords) == 1 1667s assert len(result.data_vars) == 8 1667s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1667s assert isinstance(result, Dataset) 1667s 1667s # idempotency 1667s # datetimes w/tz are preserved 1667s # column names are lost 1667s expected = df.copy() 1667s # breaks in xarray >= 2024.10.0(?) 1667s # debug print 1667s r0 = result.to_dataframe() 1667s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1667s expected.columns.name = None 1667s > tm.assert_frame_equal(result.to_dataframe(), expected) 1667s 1667s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1667s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1667s 1667s left = Index([0, 1, 2, 3], dtype='object', name='foo') 1667s right = Index([0, 1, 2, 3], dtype='UInt16', name='foo'), obj = 'DataFrame.index' 1667s 1667s def _check_types(left, right, obj: str = "Index") -> None: 1667s if not exact: 1667s return 1667s 1667s assert_class_equal(left, right, exact=exact, obj=obj) 1667s assert_attr_equal("inferred_type", left, right, obj=obj) 1667s 1667s # Skip exact dtype checking when `check_categorical` is False 1667s if isinstance(left.dtype, CategoricalDtype) and isinstance( 1667s right.dtype, CategoricalDtype 1667s ): 1667s if check_categorical: 1667s assert_attr_equal("dtype", left, right, obj=obj) 1667s assert_index_equal(left.categories, right.categories, exact=exact) 1667s return 1667s 1667s > assert_attr_equal("dtype", left, right, obj=obj) 1667s E AssertionError: DataFrame.index are different 1667s E 1667s E Attribute "dtype" are different 1667s E [left]: object 1667s E [right]: UInt16 1667s 1667s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:247: AssertionError 1667s _______ TestDataFrameToXArray.test_to_xarray_index_types[nullable_float] _______ 1667s self = 1667s 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, 1667s 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, 1667s 96.0, 97.0, 98.0, 99.0], 1667s dtype='Float32') 1667s df = bar a b c d e f g h 1667s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1667s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1667s using_infer_string = False 1667s 1667s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1667s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1667s index = index_flat 1667s # MultiIndex is tested in test_to_xarray_with_multiindex 1667s if len(index) == 0: 1667s pytest.skip("Test doesn't make sense for empty index") 1667s 1667s from xarray import Dataset 1667s 1667s df.index = index[:4] 1667s df.index.name = "foo" 1667s df.columns.name = "bar" 1667s result = df.to_xarray() 1667s assert result.sizes["foo"] == 4 1667s assert len(result.coords) == 1 1667s assert len(result.data_vars) == 8 1667s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1667s assert isinstance(result, Dataset) 1667s 1667s # idempotency 1667s # datetimes w/tz are preserved 1667s # column names are lost 1667s expected = df.copy() 1667s # breaks in xarray >= 2024.10.0(?) 1667s # debug print 1667s r0 = result.to_dataframe() 1667s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1667s expected.columns.name = None 1667s > tm.assert_frame_equal(result.to_dataframe(), expected) 1667s 1667s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1667s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1667s 1667s left = Index([0.0, 1.0, 2.0, 3.0], dtype='object', name='foo') 1667s right = Index([0.0, 1.0, 2.0, 3.0], dtype='Float32', name='foo') 1667s obj = 'DataFrame.index' 1667s 1667s def _check_types(left, right, obj: str = "Index") -> None: 1667s if not exact: 1667s return 1667s 1667s assert_class_equal(left, right, exact=exact, obj=obj) 1667s assert_attr_equal("inferred_type", left, right, obj=obj) 1667s 1667s # Skip exact dtype checking when `check_categorical` is False 1667s if isinstance(left.dtype, CategoricalDtype) and isinstance( 1667s right.dtype, CategoricalDtype 1667s ): 1667s if check_categorical: 1667s assert_attr_equal("dtype", left, right, obj=obj) 1667s assert_index_equal(left.categories, right.categories, exact=exact) 1667s return 1667s 1667s > assert_attr_equal("dtype", left, right, obj=obj) 1667s E AssertionError: DataFrame.index are different 1667s E 1667s E Attribute "dtype" are different 1667s E [left]: object 1667s E [right]: Float32 1667s 1667s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:247: AssertionError 1667s _______ TestDataFrameToXArray.test_to_xarray_index_types[nullable_bool] ________ 1667s self = 1667s index_flat = Index([False, True, True, True, True, True, True, True, True, True, 1667s True, True, True, True, True,...rue, True, True, 1667s True, True, True, True, True, True, True, True, True, True], 1667s dtype='boolean') 1667s df = bar a b c d e f g h 1667s foo ... 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1667s True d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1667s using_infer_string = False 1667s 1667s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1667s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1667s index = index_flat 1667s # MultiIndex is tested in test_to_xarray_with_multiindex 1667s if len(index) == 0: 1667s pytest.skip("Test doesn't make sense for empty index") 1667s 1667s from xarray import Dataset 1667s 1667s df.index = index[:4] 1667s df.index.name = "foo" 1667s df.columns.name = "bar" 1667s result = df.to_xarray() 1667s assert result.sizes["foo"] == 4 1667s assert len(result.coords) == 1 1667s assert len(result.data_vars) == 8 1667s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1667s assert isinstance(result, Dataset) 1667s 1667s # idempotency 1667s # datetimes w/tz are preserved 1667s # column names are lost 1667s expected = df.copy() 1667s # breaks in xarray >= 2024.10.0(?) 1667s # debug print 1667s r0 = result.to_dataframe() 1667s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1667s expected.columns.name = None 1667s > tm.assert_frame_equal(result.to_dataframe(), expected) 1667s E AssertionError: DataFrame are different 1667s E 1667s E DataFrame shape mismatch 1667s E [left]: (10, 8) 1667s E [right]: (4, 8) 1667s 1667s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: AssertionError 1667s _______ TestDataFrameToXArray.test_to_xarray_index_types[string-python] ________ 1667s self = 1667s index_flat = Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3', 'pandas_4', 'pandas_5', 1667s 'pandas_6', 'pandas_7', 'pandas_...pandas_93', 'pandas_94', 'pandas_95', 1667s 'pandas_96', 'pandas_97', 'pandas_98', 'pandas_99'], 1667s dtype='string') 1667s df = bar a b c d e f g h 1667s foo ....0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1667s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1667s using_infer_string = False 1667s 1667s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1667s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1667s index = index_flat 1667s # MultiIndex is tested in test_to_xarray_with_multiindex 1667s if len(index) == 0: 1667s pytest.skip("Test doesn't make sense for empty index") 1667s 1667s from xarray import Dataset 1667s 1667s df.index = index[:4] 1667s df.index.name = "foo" 1667s df.columns.name = "bar" 1667s result = df.to_xarray() 1667s assert result.sizes["foo"] == 4 1667s assert len(result.coords) == 1 1667s assert len(result.data_vars) == 8 1667s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1667s assert isinstance(result, Dataset) 1667s 1667s # idempotency 1667s # datetimes w/tz are preserved 1667s # column names are lost 1667s expected = df.copy() 1667s # breaks in xarray >= 2024.10.0(?) 1667s # debug print 1667s r0 = result.to_dataframe() 1667s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1667s expected.columns.name = None 1667s > tm.assert_frame_equal(result.to_dataframe(), expected) 1667s 1667s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1667s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1667s 1667s left = Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='object', name='foo') 1667s right = Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='string', name='foo') 1667s obj = 'DataFrame.index' 1667s 1667s def _check_types(left, right, obj: str = "Index") -> None: 1667s if not exact: 1667s return 1667s 1667s assert_class_equal(left, right, exact=exact, obj=obj) 1667s assert_attr_equal("inferred_type", left, right, obj=obj) 1667s 1667s # Skip exact dtype checking when `check_categorical` is False 1667s if isinstance(left.dtype, CategoricalDtype) and isinstance( 1667s right.dtype, CategoricalDtype 1667s ): 1667s if check_categorical: 1667s assert_attr_equal("dtype", left, right, obj=obj) 1667s assert_index_equal(left.categories, right.categories, exact=exact) 1667s return 1667s 1667s > assert_attr_equal("dtype", left, right, obj=obj) 1667s E AssertionError: DataFrame.index are different 1667s E 1667s E Attribute "dtype" are different 1667s E [left]: object 1667s E [right]: string[python] 1667s 1667s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:247: AssertionError 1667s =============================== warnings summary =============================== 1667s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:39 1667s /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 1667s pytestmark = pytest.mark.single_cpu 1667s 1667s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py:30 1667s /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 1667s pytestmark = pytest.mark.single_cpu 1667s 1667s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py:39 1667s /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 1667s pytestmark = pytest.mark.single_cpu 1667s 1667s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:119 1667s /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 1667s @pytest.mark.single_cpu 1667s 1667s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:125 1667s /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 1667s @pytest.mark.single_cpu 1667s 1667s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:196 1667s /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 1667s @pytest.mark.single_cpu 1667s 1667s io/pytables/test_file_handling.py: 191 warnings 1667s io/pytables/test_append.py: 21 warnings 1667s io/pytables/test_store.py: 66 warnings 1667s test_downstream.py: 26 warnings 1667s generic/test_to_xarray.py: 62 warnings 1667s /usr/lib/python3/dist-packages/py/_process/forkedfunc.py:45: DeprecationWarning: This process (pid=17380) is multi-threaded, use of fork() may lead to deadlocks in the child. 1667s pid = os.fork() 1667s 1667s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1667s /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-taib5d_a' 1667s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1667s 1667s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:429 1667s /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-w5e2piey' 1667s config.cache.set("cache/lastfailed", self.lastfailed) 1667s 1667s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1667s /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-g_b4ufm_' 1667s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1667s 1667s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1667s =========================== short test summary info ============================ 1667s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-1] 1667s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-2] 1667s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-3] 1667s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-4] 1667s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-5] 1667s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-6] 1667s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-7] 1667s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-8] 1667s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-9] 1667s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py::test_append_frame_column_oriented 1667s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py::test_select_filter_corner 1667s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py::test_frame_setitem_dask_array_into_new_col 1667s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[datetime-tz] 1667s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[bool-object] 1667s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[bool-dtype] 1667s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[categorical] 1667s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[repeats] 1667s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_int] 1667s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_uint] 1667s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_float] 1667s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_bool] 1667s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[string-python] 1667s =========== 22 failed, 335 passed, 9 skipped, 375 warnings in 31.39s =========== 1667s pymysql/psycopg2 tests, which do not work in this test environment 1668s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1668s 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" 1668s 1668s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1669s ============================= test session starts ============================== 1669s platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0 1669s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1669s rootdir: /usr/lib/python3/dist-packages/pandas/tests 1669s plugins: forked-1.6.0, localserver-0.9.0.post0, xdist-3.6.1, hypothesis-6.130.5, typeguard-4.4.2, asyncio-0.25.1, qt-4.4.0 1669s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1669s collected 2513 items 1669s 2336s ../../../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................ 2364s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_datetime.py ..................................................................................................................................................................................................................................ssssssss......................................................................................................................................................................................................................................................................................................................................................xx..........................................................................................................................................................................................................................................................................................................................................................................ssssssssss............................ 2364s 2364s ==================================== ERRORS ==================================== 2364s _______ ERROR at teardown of test_dataframe_to_sql[mysql_pymysql_engine] _______ 2364s self = , sock = None 2364s 2364s def connect(self, sock=None): 2364s self._closed = False 2364s try: 2364s if sock is None: 2364s if self.unix_socket: 2364s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2364s sock.settimeout(self.connect_timeout) 2364s sock.connect(self.unix_socket) 2364s self.host_info = "Localhost via UNIX socket" 2364s self._secure = True 2364s if DEBUG: 2364s print("connected using unix_socket") 2364s else: 2364s kwargs = {} 2364s if self.bind_address is not None: 2364s kwargs["source_address"] = (self.bind_address, 0) 2364s while True: 2364s try: 2364s > sock = socket.create_connection( 2364s (self.host, self.port), self.connect_timeout, **kwargs 2364s ) 2364s 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3.13/socket.py:864: in create_connection 2364s raise exceptions[0] 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s address = ('localhost', 3306), timeout = 10, source_address = None 2364s 2364s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2364s source_address=None, *, all_errors=False): 2364s """Connect to *address* and return the socket object. 2364s 2364s Convenience function. Connect to *address* (a 2-tuple ``(host, 2364s port)``) and return the socket object. Passing the optional 2364s *timeout* parameter will set the timeout on the socket instance 2364s before attempting to connect. If no *timeout* is supplied, the 2364s global default timeout setting returned by :func:`getdefaulttimeout` 2364s is used. If *source_address* is set it must be a tuple of (host, port) 2364s for the socket to bind as a source address before making the connection. 2364s A host of '' or port 0 tells the OS to use the default. When a connection 2364s cannot be created, raises the last error if *all_errors* is False, 2364s and an ExceptionGroup of all errors if *all_errors* is True. 2364s """ 2364s 2364s host, port = address 2364s exceptions = [] 2364s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2364s af, socktype, proto, canonname, sa = res 2364s sock = None 2364s try: 2364s sock = socket(af, socktype, proto) 2364s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2364s sock.settimeout(timeout) 2364s if source_address: 2364s sock.bind(source_address) 2364s > sock.connect(sa) 2364s E ConnectionRefusedError: [Errno 111] Connection refused 2364s 2364s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2364s 2364s During handling of the above exception, another exception occurred: 2364s 2364s self = 2364s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2364s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2364s 2364s def __init__( 2364s self, 2364s engine: Engine, 2364s connection: Optional[PoolProxiedConnection] = None, 2364s _has_events: Optional[bool] = None, 2364s _allow_revalidate: bool = True, 2364s _allow_autobegin: bool = True, 2364s ): 2364s """Construct a new Connection.""" 2364s self.engine = engine 2364s self.dialect = dialect = engine.dialect 2364s 2364s if connection is None: 2364s try: 2364s > self._dbapi_connection = engine.raw_connection() 2364s 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2364s self.connect() 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s self = , sock = None 2364s 2364s def connect(self, sock=None): 2364s self._closed = False 2364s try: 2364s if sock is None: 2364s if self.unix_socket: 2364s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2364s sock.settimeout(self.connect_timeout) 2364s sock.connect(self.unix_socket) 2364s self.host_info = "Localhost via UNIX socket" 2364s self._secure = True 2364s if DEBUG: 2364s print("connected using unix_socket") 2364s else: 2364s kwargs = {} 2364s if self.bind_address is not None: 2364s kwargs["source_address"] = (self.bind_address, 0) 2364s while True: 2364s try: 2364s sock = socket.create_connection( 2364s (self.host, self.port), self.connect_timeout, **kwargs 2364s ) 2364s break 2364s except OSError as e: 2364s if e.errno == errno.EINTR: 2364s continue 2364s raise 2364s self.host_info = "socket %s:%d" % (self.host, self.port) 2364s if DEBUG: 2364s print("connected using socket") 2364s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2364s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2364s sock.settimeout(None) 2364s 2364s self._sock = sock 2364s self._rfile = sock.makefile("rb") 2364s self._next_seq_id = 0 2364s 2364s self._get_server_information() 2364s self._request_authentication() 2364s 2364s # Send "SET NAMES" query on init for: 2364s # - Ensure charaset (and collation) is set to the server. 2364s # - collation_id in handshake packet may be ignored. 2364s # - If collation is not specified, we don't know what is server's 2364s # default collation for the charset. For example, default collation 2364s # of utf8mb4 is: 2364s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2364s # - MySQL 8.0: utf8mb4_0900_ai_ci 2364s # 2364s # Reference: 2364s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2364s # - https://github.com/wagtail/wagtail/issues/9477 2364s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2364s self.set_character_set(self.charset, self.collation) 2364s 2364s if self.sql_mode is not None: 2364s c = self.cursor() 2364s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2364s c.close() 2364s 2364s if self.init_command is not None: 2364s c = self.cursor() 2364s c.execute(self.init_command) 2364s c.close() 2364s 2364s if self.autocommit_mode is not None: 2364s self.autocommit(self.autocommit_mode) 2364s except BaseException as e: 2364s self._rfile = None 2364s if sock is not None: 2364s try: 2364s sock.close() 2364s except: # noqa 2364s pass 2364s 2364s if isinstance(e, (OSError, IOError)): 2364s exc = err.OperationalError( 2364s CR.CR_CONN_HOST_ERROR, 2364s f"Can't connect to MySQL server on {self.host!r} ({e})", 2364s ) 2364s # Keep original exception and traceback to investigate error. 2364s exc.original_exception = e 2364s exc.traceback = traceback.format_exc() 2364s if DEBUG: 2364s print(exc.traceback) 2364s > raise exc 2364s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2364s 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2364s 2364s The above exception was the direct cause of the following exception: 2364s 2364s @pytest.fixture 2364s def mysql_pymysql_engine(): 2364s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2364s pymysql = td.versioned_importorskip("pymysql") 2364s engine = sqlalchemy.create_engine( 2364s "mysql+pymysql://root@localhost:3306/pandas", 2364s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2364s poolclass=sqlalchemy.pool.NullPool, 2364s ) 2364s yield engine 2364s > for view in get_all_views(engine): 2364s 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2364s return inspect(conn).get_view_names() 2364s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2364s ret = reg(subject) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2364s return Inspector._construct(Inspector._init_engine, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2364s init(self, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2364s engine.connect().close() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2364s return self._connection_cls(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2364s Connection._handle_dbapi_exception_noconnection( 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2364s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2364s self._dbapi_connection = engine.raw_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2364s self.connect() 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s self = , sock = None 2364s 2364s def connect(self, sock=None): 2364s self._closed = False 2364s try: 2364s if sock is None: 2364s if self.unix_socket: 2364s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2364s sock.settimeout(self.connect_timeout) 2364s sock.connect(self.unix_socket) 2364s self.host_info = "Localhost via UNIX socket" 2364s self._secure = True 2364s if DEBUG: 2364s print("connected using unix_socket") 2364s else: 2364s kwargs = {} 2364s if self.bind_address is not None: 2364s kwargs["source_address"] = (self.bind_address, 0) 2364s while True: 2364s try: 2364s sock = socket.create_connection( 2364s (self.host, self.port), self.connect_timeout, **kwargs 2364s ) 2364s break 2364s except OSError as e: 2364s if e.errno == errno.EINTR: 2364s continue 2364s raise 2364s self.host_info = "socket %s:%d" % (self.host, self.port) 2364s if DEBUG: 2364s print("connected using socket") 2364s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2364s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2364s sock.settimeout(None) 2364s 2364s self._sock = sock 2364s self._rfile = sock.makefile("rb") 2364s self._next_seq_id = 0 2364s 2364s self._get_server_information() 2364s self._request_authentication() 2364s 2364s # Send "SET NAMES" query on init for: 2364s # - Ensure charaset (and collation) is set to the server. 2364s # - collation_id in handshake packet may be ignored. 2364s # - If collation is not specified, we don't know what is server's 2364s # default collation for the charset. For example, default collation 2364s # of utf8mb4 is: 2364s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2364s # - MySQL 8.0: utf8mb4_0900_ai_ci 2364s # 2364s # Reference: 2364s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2364s # - https://github.com/wagtail/wagtail/issues/9477 2364s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2364s self.set_character_set(self.charset, self.collation) 2364s 2364s if self.sql_mode is not None: 2364s c = self.cursor() 2364s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2364s c.close() 2364s 2364s if self.init_command is not None: 2364s c = self.cursor() 2364s c.execute(self.init_command) 2364s c.close() 2364s 2364s if self.autocommit_mode is not None: 2364s self.autocommit(self.autocommit_mode) 2364s except BaseException as e: 2364s self._rfile = None 2364s if sock is not None: 2364s try: 2364s sock.close() 2364s except: # noqa 2364s pass 2364s 2364s if isinstance(e, (OSError, IOError)): 2364s exc = err.OperationalError( 2364s CR.CR_CONN_HOST_ERROR, 2364s f"Can't connect to MySQL server on {self.host!r} ({e})", 2364s ) 2364s # Keep original exception and traceback to investigate error. 2364s exc.original_exception = e 2364s exc.traceback = traceback.format_exc() 2364s if DEBUG: 2364s print(exc.traceback) 2364s > raise exc 2364s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2364s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2364s 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2364s ________ ERROR at teardown of test_dataframe_to_sql[mysql_pymysql_conn] ________ 2364s self = , sock = None 2364s 2364s def connect(self, sock=None): 2364s self._closed = False 2364s try: 2364s if sock is None: 2364s if self.unix_socket: 2364s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2364s sock.settimeout(self.connect_timeout) 2364s sock.connect(self.unix_socket) 2364s self.host_info = "Localhost via UNIX socket" 2364s self._secure = True 2364s if DEBUG: 2364s print("connected using unix_socket") 2364s else: 2364s kwargs = {} 2364s if self.bind_address is not None: 2364s kwargs["source_address"] = (self.bind_address, 0) 2364s while True: 2364s try: 2364s > sock = socket.create_connection( 2364s (self.host, self.port), self.connect_timeout, **kwargs 2364s ) 2364s 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3.13/socket.py:864: in create_connection 2364s raise exceptions[0] 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s address = ('localhost', 3306), timeout = 10, source_address = None 2364s 2364s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2364s source_address=None, *, all_errors=False): 2364s """Connect to *address* and return the socket object. 2364s 2364s Convenience function. Connect to *address* (a 2-tuple ``(host, 2364s port)``) and return the socket object. Passing the optional 2364s *timeout* parameter will set the timeout on the socket instance 2364s before attempting to connect. If no *timeout* is supplied, the 2364s global default timeout setting returned by :func:`getdefaulttimeout` 2364s is used. If *source_address* is set it must be a tuple of (host, port) 2364s for the socket to bind as a source address before making the connection. 2364s A host of '' or port 0 tells the OS to use the default. When a connection 2364s cannot be created, raises the last error if *all_errors* is False, 2364s and an ExceptionGroup of all errors if *all_errors* is True. 2364s """ 2364s 2364s host, port = address 2364s exceptions = [] 2364s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2364s af, socktype, proto, canonname, sa = res 2364s sock = None 2364s try: 2364s sock = socket(af, socktype, proto) 2364s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2364s sock.settimeout(timeout) 2364s if source_address: 2364s sock.bind(source_address) 2364s > sock.connect(sa) 2364s E ConnectionRefusedError: [Errno 111] Connection refused 2364s 2364s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2364s 2364s During handling of the above exception, another exception occurred: 2364s 2364s self = 2364s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2364s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2364s 2364s def __init__( 2364s self, 2364s engine: Engine, 2364s connection: Optional[PoolProxiedConnection] = None, 2364s _has_events: Optional[bool] = None, 2364s _allow_revalidate: bool = True, 2364s _allow_autobegin: bool = True, 2364s ): 2364s """Construct a new Connection.""" 2364s self.engine = engine 2364s self.dialect = dialect = engine.dialect 2364s 2364s if connection is None: 2364s try: 2364s > self._dbapi_connection = engine.raw_connection() 2364s 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2364s self.connect() 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s self = , sock = None 2364s 2364s def connect(self, sock=None): 2364s self._closed = False 2364s try: 2364s if sock is None: 2364s if self.unix_socket: 2364s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2364s sock.settimeout(self.connect_timeout) 2364s sock.connect(self.unix_socket) 2364s self.host_info = "Localhost via UNIX socket" 2364s self._secure = True 2364s if DEBUG: 2364s print("connected using unix_socket") 2364s else: 2364s kwargs = {} 2364s if self.bind_address is not None: 2364s kwargs["source_address"] = (self.bind_address, 0) 2364s while True: 2364s try: 2364s sock = socket.create_connection( 2364s (self.host, self.port), self.connect_timeout, **kwargs 2364s ) 2364s break 2364s except OSError as e: 2364s if e.errno == errno.EINTR: 2364s continue 2364s raise 2364s self.host_info = "socket %s:%d" % (self.host, self.port) 2364s if DEBUG: 2364s print("connected using socket") 2364s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2364s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2364s sock.settimeout(None) 2364s 2364s self._sock = sock 2364s self._rfile = sock.makefile("rb") 2364s self._next_seq_id = 0 2364s 2364s self._get_server_information() 2364s self._request_authentication() 2364s 2364s # Send "SET NAMES" query on init for: 2364s # - Ensure charaset (and collation) is set to the server. 2364s # - collation_id in handshake packet may be ignored. 2364s # - If collation is not specified, we don't know what is server's 2364s # default collation for the charset. For example, default collation 2364s # of utf8mb4 is: 2364s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2364s # - MySQL 8.0: utf8mb4_0900_ai_ci 2364s # 2364s # Reference: 2364s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2364s # - https://github.com/wagtail/wagtail/issues/9477 2364s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2364s self.set_character_set(self.charset, self.collation) 2364s 2364s if self.sql_mode is not None: 2364s c = self.cursor() 2364s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2364s c.close() 2364s 2364s if self.init_command is not None: 2364s c = self.cursor() 2364s c.execute(self.init_command) 2364s c.close() 2364s 2364s if self.autocommit_mode is not None: 2364s self.autocommit(self.autocommit_mode) 2364s except BaseException as e: 2364s self._rfile = None 2364s if sock is not None: 2364s try: 2364s sock.close() 2364s except: # noqa 2364s pass 2364s 2364s if isinstance(e, (OSError, IOError)): 2364s exc = err.OperationalError( 2364s CR.CR_CONN_HOST_ERROR, 2364s f"Can't connect to MySQL server on {self.host!r} ({e})", 2364s ) 2364s # Keep original exception and traceback to investigate error. 2364s exc.original_exception = e 2364s exc.traceback = traceback.format_exc() 2364s if DEBUG: 2364s print(exc.traceback) 2364s > raise exc 2364s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2364s 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2364s 2364s The above exception was the direct cause of the following exception: 2364s 2364s @pytest.fixture 2364s def mysql_pymysql_engine(): 2364s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2364s pymysql = td.versioned_importorskip("pymysql") 2364s engine = sqlalchemy.create_engine( 2364s "mysql+pymysql://root@localhost:3306/pandas", 2364s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2364s poolclass=sqlalchemy.pool.NullPool, 2364s ) 2364s yield engine 2364s > for view in get_all_views(engine): 2364s 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2364s return inspect(conn).get_view_names() 2364s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2364s ret = reg(subject) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2364s return Inspector._construct(Inspector._init_engine, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2364s init(self, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2364s engine.connect().close() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2364s return self._connection_cls(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2364s Connection._handle_dbapi_exception_noconnection( 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2364s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2364s self._dbapi_connection = engine.raw_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2364s self.connect() 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s self = , sock = None 2364s 2364s def connect(self, sock=None): 2364s self._closed = False 2364s try: 2364s if sock is None: 2364s if self.unix_socket: 2364s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2364s sock.settimeout(self.connect_timeout) 2364s sock.connect(self.unix_socket) 2364s self.host_info = "Localhost via UNIX socket" 2364s self._secure = True 2364s if DEBUG: 2364s print("connected using unix_socket") 2364s else: 2364s kwargs = {} 2364s if self.bind_address is not None: 2364s kwargs["source_address"] = (self.bind_address, 0) 2364s while True: 2364s try: 2364s sock = socket.create_connection( 2364s (self.host, self.port), self.connect_timeout, **kwargs 2364s ) 2364s break 2364s except OSError as e: 2364s if e.errno == errno.EINTR: 2364s continue 2364s raise 2364s self.host_info = "socket %s:%d" % (self.host, self.port) 2364s if DEBUG: 2364s print("connected using socket") 2364s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2364s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2364s sock.settimeout(None) 2364s 2364s self._sock = sock 2364s self._rfile = sock.makefile("rb") 2364s self._next_seq_id = 0 2364s 2364s self._get_server_information() 2364s self._request_authentication() 2364s 2364s # Send "SET NAMES" query on init for: 2364s # - Ensure charaset (and collation) is set to the server. 2364s # - collation_id in handshake packet may be ignored. 2364s # - If collation is not specified, we don't know what is server's 2364s # default collation for the charset. For example, default collation 2364s # of utf8mb4 is: 2364s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2364s # - MySQL 8.0: utf8mb4_0900_ai_ci 2364s # 2364s # Reference: 2364s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2364s # - https://github.com/wagtail/wagtail/issues/9477 2364s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2364s self.set_character_set(self.charset, self.collation) 2364s 2364s if self.sql_mode is not None: 2364s c = self.cursor() 2364s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2364s c.close() 2364s 2364s if self.init_command is not None: 2364s c = self.cursor() 2364s c.execute(self.init_command) 2364s c.close() 2364s 2364s if self.autocommit_mode is not None: 2364s self.autocommit(self.autocommit_mode) 2364s except BaseException as e: 2364s self._rfile = None 2364s if sock is not None: 2364s try: 2364s sock.close() 2364s except: # noqa 2364s pass 2364s 2364s if isinstance(e, (OSError, IOError)): 2364s exc = err.OperationalError( 2364s CR.CR_CONN_HOST_ERROR, 2364s f"Can't connect to MySQL server on {self.host!r} ({e})", 2364s ) 2364s # Keep original exception and traceback to investigate error. 2364s exc.original_exception = e 2364s exc.traceback = traceback.format_exc() 2364s if DEBUG: 2364s print(exc.traceback) 2364s > raise exc 2364s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2364s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2364s 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2364s ____ ERROR at teardown of test_dataframe_to_sql[postgresql_psycopg2_engine] ____ 2364s self = 2364s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2364s connection = None, _has_events = None, _allow_revalidate = True 2364s _allow_autobegin = True 2364s 2364s def __init__( 2364s self, 2364s engine: Engine, 2364s connection: Optional[PoolProxiedConnection] = None, 2364s _has_events: Optional[bool] = None, 2364s _allow_revalidate: bool = True, 2364s _allow_autobegin: bool = True, 2364s ): 2364s """Construct a new Connection.""" 2364s self.engine = engine 2364s self.dialect = dialect = engine.dialect 2364s 2364s if connection is None: 2364s try: 2364s > self._dbapi_connection = engine.raw_connection() 2364s 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2364s connection_factory = None, cursor_factory = None 2364s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2364s kwasync = {} 2364s 2364s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2364s """ 2364s Create a new database connection. 2364s 2364s The connection parameters can be specified as a string: 2364s 2364s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2364s 2364s or using a set of keyword arguments: 2364s 2364s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2364s 2364s Or as a mix of both. The basic connection parameters are: 2364s 2364s - *dbname*: the database name 2364s - *database*: the database name (only as keyword argument) 2364s - *user*: user name used to authenticate 2364s - *password*: password used to authenticate 2364s - *host*: database host address (defaults to UNIX socket if not provided) 2364s - *port*: connection port number (defaults to 5432 if not provided) 2364s 2364s Using the *connection_factory* parameter a different class or connections 2364s factory can be specified. It should be a callable object taking a dsn 2364s argument. 2364s 2364s Using the *cursor_factory* parameter, a new default cursor factory will be 2364s used by cursor(). 2364s 2364s Using *async*=True an asynchronous connection will be created. *async_* is 2364s a valid alias (for Python versions where ``async`` is a keyword). 2364s 2364s Any other keyword parameter will be passed to the underlying client 2364s library: the list of supported parameters depends on the library version. 2364s 2364s """ 2364s kwasync = {} 2364s if 'async' in kwargs: 2364s kwasync['async'] = kwargs.pop('async') 2364s if 'async_' in kwargs: 2364s kwasync['async_'] = kwargs.pop('async_') 2364s 2364s dsn = _ext.make_dsn(dsn, **kwargs) 2364s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2364s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s 2364s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2364s 2364s The above exception was the direct cause of the following exception: 2364s 2364s @pytest.fixture 2364s def postgresql_psycopg2_engine(): 2364s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2364s td.versioned_importorskip("psycopg2") 2364s engine = sqlalchemy.create_engine( 2364s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2364s poolclass=sqlalchemy.pool.NullPool, 2364s ) 2364s yield engine 2364s > for view in get_all_views(engine): 2364s 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2364s return inspect(conn).get_view_names() 2364s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2364s ret = reg(subject) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2364s return Inspector._construct(Inspector._init_engine, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2364s init(self, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2364s engine.connect().close() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2364s return self._connection_cls(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2364s Connection._handle_dbapi_exception_noconnection( 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2364s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2364s self._dbapi_connection = engine.raw_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2364s connection_factory = None, cursor_factory = None 2364s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2364s kwasync = {} 2364s 2364s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2364s """ 2364s Create a new database connection. 2364s 2364s The connection parameters can be specified as a string: 2364s 2364s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2364s 2364s or using a set of keyword arguments: 2364s 2364s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2364s 2364s Or as a mix of both. The basic connection parameters are: 2364s 2364s - *dbname*: the database name 2364s - *database*: the database name (only as keyword argument) 2364s - *user*: user name used to authenticate 2364s - *password*: password used to authenticate 2364s - *host*: database host address (defaults to UNIX socket if not provided) 2364s - *port*: connection port number (defaults to 5432 if not provided) 2364s 2364s Using the *connection_factory* parameter a different class or connections 2364s factory can be specified. It should be a callable object taking a dsn 2364s argument. 2364s 2364s Using the *cursor_factory* parameter, a new default cursor factory will be 2364s used by cursor(). 2364s 2364s Using *async*=True an asynchronous connection will be created. *async_* is 2364s a valid alias (for Python versions where ``async`` is a keyword). 2364s 2364s Any other keyword parameter will be passed to the underlying client 2364s library: the list of supported parameters depends on the library version. 2364s 2364s """ 2364s kwasync = {} 2364s if 'async' in kwargs: 2364s kwasync['async'] = kwargs.pop('async') 2364s if 'async_' in kwargs: 2364s kwasync['async_'] = kwargs.pop('async_') 2364s 2364s dsn = _ext.make_dsn(dsn, **kwargs) 2364s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2364s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s E 2364s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2364s 2364s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2364s _____ ERROR at teardown of test_dataframe_to_sql[postgresql_psycopg2_conn] _____ 2364s self = 2364s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2364s connection = None, _has_events = None, _allow_revalidate = True 2364s _allow_autobegin = True 2364s 2364s def __init__( 2364s self, 2364s engine: Engine, 2364s connection: Optional[PoolProxiedConnection] = None, 2364s _has_events: Optional[bool] = None, 2364s _allow_revalidate: bool = True, 2364s _allow_autobegin: bool = True, 2364s ): 2364s """Construct a new Connection.""" 2364s self.engine = engine 2364s self.dialect = dialect = engine.dialect 2364s 2364s if connection is None: 2364s try: 2364s > self._dbapi_connection = engine.raw_connection() 2364s 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2364s connection_factory = None, cursor_factory = None 2364s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2364s kwasync = {} 2364s 2364s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2364s """ 2364s Create a new database connection. 2364s 2364s The connection parameters can be specified as a string: 2364s 2364s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2364s 2364s or using a set of keyword arguments: 2364s 2364s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2364s 2364s Or as a mix of both. The basic connection parameters are: 2364s 2364s - *dbname*: the database name 2364s - *database*: the database name (only as keyword argument) 2364s - *user*: user name used to authenticate 2364s - *password*: password used to authenticate 2364s - *host*: database host address (defaults to UNIX socket if not provided) 2364s - *port*: connection port number (defaults to 5432 if not provided) 2364s 2364s Using the *connection_factory* parameter a different class or connections 2364s factory can be specified. It should be a callable object taking a dsn 2364s argument. 2364s 2364s Using the *cursor_factory* parameter, a new default cursor factory will be 2364s used by cursor(). 2364s 2364s Using *async*=True an asynchronous connection will be created. *async_* is 2364s a valid alias (for Python versions where ``async`` is a keyword). 2364s 2364s Any other keyword parameter will be passed to the underlying client 2364s library: the list of supported parameters depends on the library version. 2364s 2364s """ 2364s kwasync = {} 2364s if 'async' in kwargs: 2364s kwasync['async'] = kwargs.pop('async') 2364s if 'async_' in kwargs: 2364s kwasync['async_'] = kwargs.pop('async_') 2364s 2364s dsn = _ext.make_dsn(dsn, **kwargs) 2364s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2364s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s 2364s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2364s 2364s The above exception was the direct cause of the following exception: 2364s 2364s @pytest.fixture 2364s def postgresql_psycopg2_engine(): 2364s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2364s td.versioned_importorskip("psycopg2") 2364s engine = sqlalchemy.create_engine( 2364s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2364s poolclass=sqlalchemy.pool.NullPool, 2364s ) 2364s yield engine 2364s > for view in get_all_views(engine): 2364s 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2364s return inspect(conn).get_view_names() 2364s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2364s ret = reg(subject) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2364s return Inspector._construct(Inspector._init_engine, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2364s init(self, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2364s engine.connect().close() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2364s return self._connection_cls(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2364s Connection._handle_dbapi_exception_noconnection( 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2364s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2364s self._dbapi_connection = engine.raw_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2364s connection_factory = None, cursor_factory = None 2364s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2364s kwasync = {} 2364s 2364s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2364s """ 2364s Create a new database connection. 2364s 2364s The connection parameters can be specified as a string: 2364s 2364s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2364s 2364s or using a set of keyword arguments: 2364s 2364s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2364s 2364s Or as a mix of both. The basic connection parameters are: 2364s 2364s - *dbname*: the database name 2364s - *database*: the database name (only as keyword argument) 2364s - *user*: user name used to authenticate 2364s - *password*: password used to authenticate 2364s - *host*: database host address (defaults to UNIX socket if not provided) 2364s - *port*: connection port number (defaults to 5432 if not provided) 2364s 2364s Using the *connection_factory* parameter a different class or connections 2364s factory can be specified. It should be a callable object taking a dsn 2364s argument. 2364s 2364s Using the *cursor_factory* parameter, a new default cursor factory will be 2364s used by cursor(). 2364s 2364s Using *async*=True an asynchronous connection will be created. *async_* is 2364s a valid alias (for Python versions where ``async`` is a keyword). 2364s 2364s Any other keyword parameter will be passed to the underlying client 2364s library: the list of supported parameters depends on the library version. 2364s 2364s """ 2364s kwasync = {} 2364s if 'async' in kwargs: 2364s kwasync['async'] = kwargs.pop('async') 2364s if 'async_' in kwargs: 2364s kwasync['async_'] = kwargs.pop('async_') 2364s 2364s dsn = _ext.make_dsn(dsn, **kwargs) 2364s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2364s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s E 2364s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2364s 2364s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2364s ____ ERROR at teardown of test_dataframe_to_sql_empty[mysql_pymysql_engine] ____ 2364s self = , sock = None 2364s 2364s def connect(self, sock=None): 2364s self._closed = False 2364s try: 2364s if sock is None: 2364s if self.unix_socket: 2364s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2364s sock.settimeout(self.connect_timeout) 2364s sock.connect(self.unix_socket) 2364s self.host_info = "Localhost via UNIX socket" 2364s self._secure = True 2364s if DEBUG: 2364s print("connected using unix_socket") 2364s else: 2364s kwargs = {} 2364s if self.bind_address is not None: 2364s kwargs["source_address"] = (self.bind_address, 0) 2364s while True: 2364s try: 2364s > sock = socket.create_connection( 2364s (self.host, self.port), self.connect_timeout, **kwargs 2364s ) 2364s 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3.13/socket.py:864: in create_connection 2364s raise exceptions[0] 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s address = ('localhost', 3306), timeout = 10, source_address = None 2364s 2364s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2364s source_address=None, *, all_errors=False): 2364s """Connect to *address* and return the socket object. 2364s 2364s Convenience function. Connect to *address* (a 2-tuple ``(host, 2364s port)``) and return the socket object. Passing the optional 2364s *timeout* parameter will set the timeout on the socket instance 2364s before attempting to connect. If no *timeout* is supplied, the 2364s global default timeout setting returned by :func:`getdefaulttimeout` 2364s is used. If *source_address* is set it must be a tuple of (host, port) 2364s for the socket to bind as a source address before making the connection. 2364s A host of '' or port 0 tells the OS to use the default. When a connection 2364s cannot be created, raises the last error if *all_errors* is False, 2364s and an ExceptionGroup of all errors if *all_errors* is True. 2364s """ 2364s 2364s host, port = address 2364s exceptions = [] 2364s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2364s af, socktype, proto, canonname, sa = res 2364s sock = None 2364s try: 2364s sock = socket(af, socktype, proto) 2364s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2364s sock.settimeout(timeout) 2364s if source_address: 2364s sock.bind(source_address) 2364s > sock.connect(sa) 2364s E ConnectionRefusedError: [Errno 111] Connection refused 2364s 2364s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2364s 2364s During handling of the above exception, another exception occurred: 2364s 2364s self = 2364s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2364s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2364s 2364s def __init__( 2364s self, 2364s engine: Engine, 2364s connection: Optional[PoolProxiedConnection] = None, 2364s _has_events: Optional[bool] = None, 2364s _allow_revalidate: bool = True, 2364s _allow_autobegin: bool = True, 2364s ): 2364s """Construct a new Connection.""" 2364s self.engine = engine 2364s self.dialect = dialect = engine.dialect 2364s 2364s if connection is None: 2364s try: 2364s > self._dbapi_connection = engine.raw_connection() 2364s 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2364s self.connect() 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s self = , sock = None 2364s 2364s def connect(self, sock=None): 2364s self._closed = False 2364s try: 2364s if sock is None: 2364s if self.unix_socket: 2364s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2364s sock.settimeout(self.connect_timeout) 2364s sock.connect(self.unix_socket) 2364s self.host_info = "Localhost via UNIX socket" 2364s self._secure = True 2364s if DEBUG: 2364s print("connected using unix_socket") 2364s else: 2364s kwargs = {} 2364s if self.bind_address is not None: 2364s kwargs["source_address"] = (self.bind_address, 0) 2364s while True: 2364s try: 2364s sock = socket.create_connection( 2364s (self.host, self.port), self.connect_timeout, **kwargs 2364s ) 2364s break 2364s except OSError as e: 2364s if e.errno == errno.EINTR: 2364s continue 2364s raise 2364s self.host_info = "socket %s:%d" % (self.host, self.port) 2364s if DEBUG: 2364s print("connected using socket") 2364s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2364s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2364s sock.settimeout(None) 2364s 2364s self._sock = sock 2364s self._rfile = sock.makefile("rb") 2364s self._next_seq_id = 0 2364s 2364s self._get_server_information() 2364s self._request_authentication() 2364s 2364s # Send "SET NAMES" query on init for: 2364s # - Ensure charaset (and collation) is set to the server. 2364s # - collation_id in handshake packet may be ignored. 2364s # - If collation is not specified, we don't know what is server's 2364s # default collation for the charset. For example, default collation 2364s # of utf8mb4 is: 2364s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2364s # - MySQL 8.0: utf8mb4_0900_ai_ci 2364s # 2364s # Reference: 2364s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2364s # - https://github.com/wagtail/wagtail/issues/9477 2364s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2364s self.set_character_set(self.charset, self.collation) 2364s 2364s if self.sql_mode is not None: 2364s c = self.cursor() 2364s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2364s c.close() 2364s 2364s if self.init_command is not None: 2364s c = self.cursor() 2364s c.execute(self.init_command) 2364s c.close() 2364s 2364s if self.autocommit_mode is not None: 2364s self.autocommit(self.autocommit_mode) 2364s except BaseException as e: 2364s self._rfile = None 2364s if sock is not None: 2364s try: 2364s sock.close() 2364s except: # noqa 2364s pass 2364s 2364s if isinstance(e, (OSError, IOError)): 2364s exc = err.OperationalError( 2364s CR.CR_CONN_HOST_ERROR, 2364s f"Can't connect to MySQL server on {self.host!r} ({e})", 2364s ) 2364s # Keep original exception and traceback to investigate error. 2364s exc.original_exception = e 2364s exc.traceback = traceback.format_exc() 2364s if DEBUG: 2364s print(exc.traceback) 2364s > raise exc 2364s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2364s 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2364s 2364s The above exception was the direct cause of the following exception: 2364s 2364s @pytest.fixture 2364s def mysql_pymysql_engine(): 2364s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2364s pymysql = td.versioned_importorskip("pymysql") 2364s engine = sqlalchemy.create_engine( 2364s "mysql+pymysql://root@localhost:3306/pandas", 2364s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2364s poolclass=sqlalchemy.pool.NullPool, 2364s ) 2364s yield engine 2364s > for view in get_all_views(engine): 2364s 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2364s return inspect(conn).get_view_names() 2364s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2364s ret = reg(subject) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2364s return Inspector._construct(Inspector._init_engine, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2364s init(self, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2364s engine.connect().close() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2364s return self._connection_cls(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2364s Connection._handle_dbapi_exception_noconnection( 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2364s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2364s self._dbapi_connection = engine.raw_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2364s self.connect() 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s self = , sock = None 2364s 2364s def connect(self, sock=None): 2364s self._closed = False 2364s try: 2364s if sock is None: 2364s if self.unix_socket: 2364s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2364s sock.settimeout(self.connect_timeout) 2364s sock.connect(self.unix_socket) 2364s self.host_info = "Localhost via UNIX socket" 2364s self._secure = True 2364s if DEBUG: 2364s print("connected using unix_socket") 2364s else: 2364s kwargs = {} 2364s if self.bind_address is not None: 2364s kwargs["source_address"] = (self.bind_address, 0) 2364s while True: 2364s try: 2364s sock = socket.create_connection( 2364s (self.host, self.port), self.connect_timeout, **kwargs 2364s ) 2364s break 2364s except OSError as e: 2364s if e.errno == errno.EINTR: 2364s continue 2364s raise 2364s self.host_info = "socket %s:%d" % (self.host, self.port) 2364s if DEBUG: 2364s print("connected using socket") 2364s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2364s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2364s sock.settimeout(None) 2364s 2364s self._sock = sock 2364s self._rfile = sock.makefile("rb") 2364s self._next_seq_id = 0 2364s 2364s self._get_server_information() 2364s self._request_authentication() 2364s 2364s # Send "SET NAMES" query on init for: 2364s # - Ensure charaset (and collation) is set to the server. 2364s # - collation_id in handshake packet may be ignored. 2364s # - If collation is not specified, we don't know what is server's 2364s # default collation for the charset. For example, default collation 2364s # of utf8mb4 is: 2364s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2364s # - MySQL 8.0: utf8mb4_0900_ai_ci 2364s # 2364s # Reference: 2364s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2364s # - https://github.com/wagtail/wagtail/issues/9477 2364s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2364s self.set_character_set(self.charset, self.collation) 2364s 2364s if self.sql_mode is not None: 2364s c = self.cursor() 2364s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2364s c.close() 2364s 2364s if self.init_command is not None: 2364s c = self.cursor() 2364s c.execute(self.init_command) 2364s c.close() 2364s 2364s if self.autocommit_mode is not None: 2364s self.autocommit(self.autocommit_mode) 2364s except BaseException as e: 2364s self._rfile = None 2364s if sock is not None: 2364s try: 2364s sock.close() 2364s except: # noqa 2364s pass 2364s 2364s if isinstance(e, (OSError, IOError)): 2364s exc = err.OperationalError( 2364s CR.CR_CONN_HOST_ERROR, 2364s f"Can't connect to MySQL server on {self.host!r} ({e})", 2364s ) 2364s # Keep original exception and traceback to investigate error. 2364s exc.original_exception = e 2364s exc.traceback = traceback.format_exc() 2364s if DEBUG: 2364s print(exc.traceback) 2364s > raise exc 2364s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2364s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2364s 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2364s _____ ERROR at teardown of test_dataframe_to_sql_empty[mysql_pymysql_conn] _____ 2364s self = , sock = None 2364s 2364s def connect(self, sock=None): 2364s self._closed = False 2364s try: 2364s if sock is None: 2364s if self.unix_socket: 2364s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2364s sock.settimeout(self.connect_timeout) 2364s sock.connect(self.unix_socket) 2364s self.host_info = "Localhost via UNIX socket" 2364s self._secure = True 2364s if DEBUG: 2364s print("connected using unix_socket") 2364s else: 2364s kwargs = {} 2364s if self.bind_address is not None: 2364s kwargs["source_address"] = (self.bind_address, 0) 2364s while True: 2364s try: 2364s > sock = socket.create_connection( 2364s (self.host, self.port), self.connect_timeout, **kwargs 2364s ) 2364s 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3.13/socket.py:864: in create_connection 2364s raise exceptions[0] 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s address = ('localhost', 3306), timeout = 10, source_address = None 2364s 2364s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2364s source_address=None, *, all_errors=False): 2364s """Connect to *address* and return the socket object. 2364s 2364s Convenience function. Connect to *address* (a 2-tuple ``(host, 2364s port)``) and return the socket object. Passing the optional 2364s *timeout* parameter will set the timeout on the socket instance 2364s before attempting to connect. If no *timeout* is supplied, the 2364s global default timeout setting returned by :func:`getdefaulttimeout` 2364s is used. If *source_address* is set it must be a tuple of (host, port) 2364s for the socket to bind as a source address before making the connection. 2364s A host of '' or port 0 tells the OS to use the default. When a connection 2364s cannot be created, raises the last error if *all_errors* is False, 2364s and an ExceptionGroup of all errors if *all_errors* is True. 2364s """ 2364s 2364s host, port = address 2364s exceptions = [] 2364s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2364s af, socktype, proto, canonname, sa = res 2364s sock = None 2364s try: 2364s sock = socket(af, socktype, proto) 2364s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2364s sock.settimeout(timeout) 2364s if source_address: 2364s sock.bind(source_address) 2364s > sock.connect(sa) 2364s E ConnectionRefusedError: [Errno 111] Connection refused 2364s 2364s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2364s 2364s During handling of the above exception, another exception occurred: 2364s 2364s self = 2364s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2364s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2364s 2364s def __init__( 2364s self, 2364s engine: Engine, 2364s connection: Optional[PoolProxiedConnection] = None, 2364s _has_events: Optional[bool] = None, 2364s _allow_revalidate: bool = True, 2364s _allow_autobegin: bool = True, 2364s ): 2364s """Construct a new Connection.""" 2364s self.engine = engine 2364s self.dialect = dialect = engine.dialect 2364s 2364s if connection is None: 2364s try: 2364s > self._dbapi_connection = engine.raw_connection() 2364s 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2364s self.connect() 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s self = , sock = None 2364s 2364s def connect(self, sock=None): 2364s self._closed = False 2364s try: 2364s if sock is None: 2364s if self.unix_socket: 2364s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2364s sock.settimeout(self.connect_timeout) 2364s sock.connect(self.unix_socket) 2364s self.host_info = "Localhost via UNIX socket" 2364s self._secure = True 2364s if DEBUG: 2364s print("connected using unix_socket") 2364s else: 2364s kwargs = {} 2364s if self.bind_address is not None: 2364s kwargs["source_address"] = (self.bind_address, 0) 2364s while True: 2364s try: 2364s sock = socket.create_connection( 2364s (self.host, self.port), self.connect_timeout, **kwargs 2364s ) 2364s break 2364s except OSError as e: 2364s if e.errno == errno.EINTR: 2364s continue 2364s raise 2364s self.host_info = "socket %s:%d" % (self.host, self.port) 2364s if DEBUG: 2364s print("connected using socket") 2364s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2364s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2364s sock.settimeout(None) 2364s 2364s self._sock = sock 2364s self._rfile = sock.makefile("rb") 2364s self._next_seq_id = 0 2364s 2364s self._get_server_information() 2364s self._request_authentication() 2364s 2364s # Send "SET NAMES" query on init for: 2364s # - Ensure charaset (and collation) is set to the server. 2364s # - collation_id in handshake packet may be ignored. 2364s # - If collation is not specified, we don't know what is server's 2364s # default collation for the charset. For example, default collation 2364s # of utf8mb4 is: 2364s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2364s # - MySQL 8.0: utf8mb4_0900_ai_ci 2364s # 2364s # Reference: 2364s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2364s # - https://github.com/wagtail/wagtail/issues/9477 2364s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2364s self.set_character_set(self.charset, self.collation) 2364s 2364s if self.sql_mode is not None: 2364s c = self.cursor() 2364s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2364s c.close() 2364s 2364s if self.init_command is not None: 2364s c = self.cursor() 2364s c.execute(self.init_command) 2364s c.close() 2364s 2364s if self.autocommit_mode is not None: 2364s self.autocommit(self.autocommit_mode) 2364s except BaseException as e: 2364s self._rfile = None 2364s if sock is not None: 2364s try: 2364s sock.close() 2364s except: # noqa 2364s pass 2364s 2364s if isinstance(e, (OSError, IOError)): 2364s exc = err.OperationalError( 2364s CR.CR_CONN_HOST_ERROR, 2364s f"Can't connect to MySQL server on {self.host!r} ({e})", 2364s ) 2364s # Keep original exception and traceback to investigate error. 2364s exc.original_exception = e 2364s exc.traceback = traceback.format_exc() 2364s if DEBUG: 2364s print(exc.traceback) 2364s > raise exc 2364s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2364s 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2364s 2364s The above exception was the direct cause of the following exception: 2364s 2364s @pytest.fixture 2364s def mysql_pymysql_engine(): 2364s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2364s pymysql = td.versioned_importorskip("pymysql") 2364s engine = sqlalchemy.create_engine( 2364s "mysql+pymysql://root@localhost:3306/pandas", 2364s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2364s poolclass=sqlalchemy.pool.NullPool, 2364s ) 2364s yield engine 2364s > for view in get_all_views(engine): 2364s 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2364s return inspect(conn).get_view_names() 2364s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2364s ret = reg(subject) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2364s return Inspector._construct(Inspector._init_engine, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2364s init(self, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2364s engine.connect().close() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2364s return self._connection_cls(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2364s Connection._handle_dbapi_exception_noconnection( 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2364s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2364s self._dbapi_connection = engine.raw_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2364s self.connect() 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s self = , sock = None 2364s 2364s def connect(self, sock=None): 2364s self._closed = False 2364s try: 2364s if sock is None: 2364s if self.unix_socket: 2364s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2364s sock.settimeout(self.connect_timeout) 2364s sock.connect(self.unix_socket) 2364s self.host_info = "Localhost via UNIX socket" 2364s self._secure = True 2364s if DEBUG: 2364s print("connected using unix_socket") 2364s else: 2364s kwargs = {} 2364s if self.bind_address is not None: 2364s kwargs["source_address"] = (self.bind_address, 0) 2364s while True: 2364s try: 2364s sock = socket.create_connection( 2364s (self.host, self.port), self.connect_timeout, **kwargs 2364s ) 2364s break 2364s except OSError as e: 2364s if e.errno == errno.EINTR: 2364s continue 2364s raise 2364s self.host_info = "socket %s:%d" % (self.host, self.port) 2364s if DEBUG: 2364s print("connected using socket") 2364s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2364s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2364s sock.settimeout(None) 2364s 2364s self._sock = sock 2364s self._rfile = sock.makefile("rb") 2364s self._next_seq_id = 0 2364s 2364s self._get_server_information() 2364s self._request_authentication() 2364s 2364s # Send "SET NAMES" query on init for: 2364s # - Ensure charaset (and collation) is set to the server. 2364s # - collation_id in handshake packet may be ignored. 2364s # - If collation is not specified, we don't know what is server's 2364s # default collation for the charset. For example, default collation 2364s # of utf8mb4 is: 2364s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2364s # - MySQL 8.0: utf8mb4_0900_ai_ci 2364s # 2364s # Reference: 2364s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2364s # - https://github.com/wagtail/wagtail/issues/9477 2364s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2364s self.set_character_set(self.charset, self.collation) 2364s 2364s if self.sql_mode is not None: 2364s c = self.cursor() 2364s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2364s c.close() 2364s 2364s if self.init_command is not None: 2364s c = self.cursor() 2364s c.execute(self.init_command) 2364s c.close() 2364s 2364s if self.autocommit_mode is not None: 2364s self.autocommit(self.autocommit_mode) 2364s except BaseException as e: 2364s self._rfile = None 2364s if sock is not None: 2364s try: 2364s sock.close() 2364s except: # noqa 2364s pass 2364s 2364s if isinstance(e, (OSError, IOError)): 2364s exc = err.OperationalError( 2364s CR.CR_CONN_HOST_ERROR, 2364s f"Can't connect to MySQL server on {self.host!r} ({e})", 2364s ) 2364s # Keep original exception and traceback to investigate error. 2364s exc.original_exception = e 2364s exc.traceback = traceback.format_exc() 2364s if DEBUG: 2364s print(exc.traceback) 2364s > raise exc 2364s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2364s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2364s 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2364s _ ERROR at teardown of test_dataframe_to_sql_empty[postgresql_psycopg2_engine] _ 2364s self = 2364s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2364s connection = None, _has_events = None, _allow_revalidate = True 2364s _allow_autobegin = True 2364s 2364s def __init__( 2364s self, 2364s engine: Engine, 2364s connection: Optional[PoolProxiedConnection] = None, 2364s _has_events: Optional[bool] = None, 2364s _allow_revalidate: bool = True, 2364s _allow_autobegin: bool = True, 2364s ): 2364s """Construct a new Connection.""" 2364s self.engine = engine 2364s self.dialect = dialect = engine.dialect 2364s 2364s if connection is None: 2364s try: 2364s > self._dbapi_connection = engine.raw_connection() 2364s 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2364s connection_factory = None, cursor_factory = None 2364s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2364s kwasync = {} 2364s 2364s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2364s """ 2364s Create a new database connection. 2364s 2364s The connection parameters can be specified as a string: 2364s 2364s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2364s 2364s or using a set of keyword arguments: 2364s 2364s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2364s 2364s Or as a mix of both. The basic connection parameters are: 2364s 2364s - *dbname*: the database name 2364s - *database*: the database name (only as keyword argument) 2364s - *user*: user name used to authenticate 2364s - *password*: password used to authenticate 2364s - *host*: database host address (defaults to UNIX socket if not provided) 2364s - *port*: connection port number (defaults to 5432 if not provided) 2364s 2364s Using the *connection_factory* parameter a different class or connections 2364s factory can be specified. It should be a callable object taking a dsn 2364s argument. 2364s 2364s Using the *cursor_factory* parameter, a new default cursor factory will be 2364s used by cursor(). 2364s 2364s Using *async*=True an asynchronous connection will be created. *async_* is 2364s a valid alias (for Python versions where ``async`` is a keyword). 2364s 2364s Any other keyword parameter will be passed to the underlying client 2364s library: the list of supported parameters depends on the library version. 2364s 2364s """ 2364s kwasync = {} 2364s if 'async' in kwargs: 2364s kwasync['async'] = kwargs.pop('async') 2364s if 'async_' in kwargs: 2364s kwasync['async_'] = kwargs.pop('async_') 2364s 2364s dsn = _ext.make_dsn(dsn, **kwargs) 2364s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2364s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s 2364s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2364s 2364s The above exception was the direct cause of the following exception: 2364s 2364s @pytest.fixture 2364s def postgresql_psycopg2_engine(): 2364s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2364s td.versioned_importorskip("psycopg2") 2364s engine = sqlalchemy.create_engine( 2364s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2364s poolclass=sqlalchemy.pool.NullPool, 2364s ) 2364s yield engine 2364s > for view in get_all_views(engine): 2364s 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2364s return inspect(conn).get_view_names() 2364s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2364s ret = reg(subject) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2364s return Inspector._construct(Inspector._init_engine, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2364s init(self, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2364s engine.connect().close() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2364s return self._connection_cls(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2364s Connection._handle_dbapi_exception_noconnection( 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2364s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2364s self._dbapi_connection = engine.raw_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2364s connection_factory = None, cursor_factory = None 2364s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2364s kwasync = {} 2364s 2364s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2364s """ 2364s Create a new database connection. 2364s 2364s The connection parameters can be specified as a string: 2364s 2364s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2364s 2364s or using a set of keyword arguments: 2364s 2364s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2364s 2364s Or as a mix of both. The basic connection parameters are: 2364s 2364s - *dbname*: the database name 2364s - *database*: the database name (only as keyword argument) 2364s - *user*: user name used to authenticate 2364s - *password*: password used to authenticate 2364s - *host*: database host address (defaults to UNIX socket if not provided) 2364s - *port*: connection port number (defaults to 5432 if not provided) 2364s 2364s Using the *connection_factory* parameter a different class or connections 2364s factory can be specified. It should be a callable object taking a dsn 2364s argument. 2364s 2364s Using the *cursor_factory* parameter, a new default cursor factory will be 2364s used by cursor(). 2364s 2364s Using *async*=True an asynchronous connection will be created. *async_* is 2364s a valid alias (for Python versions where ``async`` is a keyword). 2364s 2364s Any other keyword parameter will be passed to the underlying client 2364s library: the list of supported parameters depends on the library version. 2364s 2364s """ 2364s kwasync = {} 2364s if 'async' in kwargs: 2364s kwasync['async'] = kwargs.pop('async') 2364s if 'async_' in kwargs: 2364s kwasync['async_'] = kwargs.pop('async_') 2364s 2364s dsn = _ext.make_dsn(dsn, **kwargs) 2364s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2364s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s E 2364s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2364s 2364s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2364s __ ERROR at teardown of test_dataframe_to_sql_empty[postgresql_psycopg2_conn] __ 2364s self = 2364s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2364s connection = None, _has_events = None, _allow_revalidate = True 2364s _allow_autobegin = True 2364s 2364s def __init__( 2364s self, 2364s engine: Engine, 2364s connection: Optional[PoolProxiedConnection] = None, 2364s _has_events: Optional[bool] = None, 2364s _allow_revalidate: bool = True, 2364s _allow_autobegin: bool = True, 2364s ): 2364s """Construct a new Connection.""" 2364s self.engine = engine 2364s self.dialect = dialect = engine.dialect 2364s 2364s if connection is None: 2364s try: 2364s > self._dbapi_connection = engine.raw_connection() 2364s 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2364s connection_factory = None, cursor_factory = None 2364s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2364s kwasync = {} 2364s 2364s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2364s """ 2364s Create a new database connection. 2364s 2364s The connection parameters can be specified as a string: 2364s 2364s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2364s 2364s or using a set of keyword arguments: 2364s 2364s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2364s 2364s Or as a mix of both. The basic connection parameters are: 2364s 2364s - *dbname*: the database name 2364s - *database*: the database name (only as keyword argument) 2364s - *user*: user name used to authenticate 2364s - *password*: password used to authenticate 2364s - *host*: database host address (defaults to UNIX socket if not provided) 2364s - *port*: connection port number (defaults to 5432 if not provided) 2364s 2364s Using the *connection_factory* parameter a different class or connections 2364s factory can be specified. It should be a callable object taking a dsn 2364s argument. 2364s 2364s Using the *cursor_factory* parameter, a new default cursor factory will be 2364s used by cursor(). 2364s 2364s Using *async*=True an asynchronous connection will be created. *async_* is 2364s a valid alias (for Python versions where ``async`` is a keyword). 2364s 2364s Any other keyword parameter will be passed to the underlying client 2364s library: the list of supported parameters depends on the library version. 2364s 2364s """ 2364s kwasync = {} 2364s if 'async' in kwargs: 2364s kwasync['async'] = kwargs.pop('async') 2364s if 'async_' in kwargs: 2364s kwasync['async_'] = kwargs.pop('async_') 2364s 2364s dsn = _ext.make_dsn(dsn, **kwargs) 2364s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2364s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s 2364s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2364s 2364s The above exception was the direct cause of the following exception: 2364s 2364s @pytest.fixture 2364s def postgresql_psycopg2_engine(): 2364s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2364s td.versioned_importorskip("psycopg2") 2364s engine = sqlalchemy.create_engine( 2364s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2364s poolclass=sqlalchemy.pool.NullPool, 2364s ) 2364s yield engine 2364s > for view in get_all_views(engine): 2364s 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2364s return inspect(conn).get_view_names() 2364s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2364s ret = reg(subject) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2364s return Inspector._construct(Inspector._init_engine, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2364s init(self, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2364s engine.connect().close() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2364s return self._connection_cls(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2364s Connection._handle_dbapi_exception_noconnection( 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2364s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2364s self._dbapi_connection = engine.raw_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2364s connection_factory = None, cursor_factory = None 2364s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2364s kwasync = {} 2364s 2364s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2364s """ 2364s Create a new database connection. 2364s 2364s The connection parameters can be specified as a string: 2364s 2364s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2364s 2364s or using a set of keyword arguments: 2364s 2364s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2364s 2364s Or as a mix of both. The basic connection parameters are: 2364s 2364s - *dbname*: the database name 2364s - *database*: the database name (only as keyword argument) 2364s - *user*: user name used to authenticate 2364s - *password*: password used to authenticate 2364s - *host*: database host address (defaults to UNIX socket if not provided) 2364s - *port*: connection port number (defaults to 5432 if not provided) 2364s 2364s Using the *connection_factory* parameter a different class or connections 2364s factory can be specified. It should be a callable object taking a dsn 2364s argument. 2364s 2364s Using the *cursor_factory* parameter, a new default cursor factory will be 2364s used by cursor(). 2364s 2364s Using *async*=True an asynchronous connection will be created. *async_* is 2364s a valid alias (for Python versions where ``async`` is a keyword). 2364s 2364s Any other keyword parameter will be passed to the underlying client 2364s library: the list of supported parameters depends on the library version. 2364s 2364s """ 2364s kwasync = {} 2364s if 'async' in kwargs: 2364s kwasync['async'] = kwargs.pop('async') 2364s if 'async_' in kwargs: 2364s kwasync['async_'] = kwargs.pop('async_') 2364s 2364s dsn = _ext.make_dsn(dsn, **kwargs) 2364s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2364s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s E 2364s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2364s 2364s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2364s _________ ERROR at teardown of test_to_sql[None-mysql_pymysql_engine] __________ 2364s self = , sock = None 2364s 2364s def connect(self, sock=None): 2364s self._closed = False 2364s try: 2364s if sock is None: 2364s if self.unix_socket: 2364s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2364s sock.settimeout(self.connect_timeout) 2364s sock.connect(self.unix_socket) 2364s self.host_info = "Localhost via UNIX socket" 2364s self._secure = True 2364s if DEBUG: 2364s print("connected using unix_socket") 2364s else: 2364s kwargs = {} 2364s if self.bind_address is not None: 2364s kwargs["source_address"] = (self.bind_address, 0) 2364s while True: 2364s try: 2364s > sock = socket.create_connection( 2364s (self.host, self.port), self.connect_timeout, **kwargs 2364s ) 2364s 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3.13/socket.py:864: in create_connection 2364s raise exceptions[0] 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s address = ('localhost', 3306), timeout = 10, source_address = None 2364s 2364s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2364s source_address=None, *, all_errors=False): 2364s """Connect to *address* and return the socket object. 2364s 2364s Convenience function. Connect to *address* (a 2-tuple ``(host, 2364s port)``) and return the socket object. Passing the optional 2364s *timeout* parameter will set the timeout on the socket instance 2364s before attempting to connect. If no *timeout* is supplied, the 2364s global default timeout setting returned by :func:`getdefaulttimeout` 2364s is used. If *source_address* is set it must be a tuple of (host, port) 2364s for the socket to bind as a source address before making the connection. 2364s A host of '' or port 0 tells the OS to use the default. When a connection 2364s cannot be created, raises the last error if *all_errors* is False, 2364s and an ExceptionGroup of all errors if *all_errors* is True. 2364s """ 2364s 2364s host, port = address 2364s exceptions = [] 2364s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2364s af, socktype, proto, canonname, sa = res 2364s sock = None 2364s try: 2364s sock = socket(af, socktype, proto) 2364s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2364s sock.settimeout(timeout) 2364s if source_address: 2364s sock.bind(source_address) 2364s > sock.connect(sa) 2364s E ConnectionRefusedError: [Errno 111] Connection refused 2364s 2364s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2364s 2364s During handling of the above exception, another exception occurred: 2364s 2364s self = 2364s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2364s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2364s 2364s def __init__( 2364s self, 2364s engine: Engine, 2364s connection: Optional[PoolProxiedConnection] = None, 2364s _has_events: Optional[bool] = None, 2364s _allow_revalidate: bool = True, 2364s _allow_autobegin: bool = True, 2364s ): 2364s """Construct a new Connection.""" 2364s self.engine = engine 2364s self.dialect = dialect = engine.dialect 2364s 2364s if connection is None: 2364s try: 2364s > self._dbapi_connection = engine.raw_connection() 2364s 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2364s self.connect() 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s self = , sock = None 2364s 2364s def connect(self, sock=None): 2364s self._closed = False 2364s try: 2364s if sock is None: 2364s if self.unix_socket: 2364s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2364s sock.settimeout(self.connect_timeout) 2364s sock.connect(self.unix_socket) 2364s self.host_info = "Localhost via UNIX socket" 2364s self._secure = True 2364s if DEBUG: 2364s print("connected using unix_socket") 2364s else: 2364s kwargs = {} 2364s if self.bind_address is not None: 2364s kwargs["source_address"] = (self.bind_address, 0) 2364s while True: 2364s try: 2364s sock = socket.create_connection( 2364s (self.host, self.port), self.connect_timeout, **kwargs 2364s ) 2364s break 2364s except OSError as e: 2364s if e.errno == errno.EINTR: 2364s continue 2364s raise 2364s self.host_info = "socket %s:%d" % (self.host, self.port) 2364s if DEBUG: 2364s print("connected using socket") 2364s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2364s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2364s sock.settimeout(None) 2364s 2364s self._sock = sock 2364s self._rfile = sock.makefile("rb") 2364s self._next_seq_id = 0 2364s 2364s self._get_server_information() 2364s self._request_authentication() 2364s 2364s # Send "SET NAMES" query on init for: 2364s # - Ensure charaset (and collation) is set to the server. 2364s # - collation_id in handshake packet may be ignored. 2364s # - If collation is not specified, we don't know what is server's 2364s # default collation for the charset. For example, default collation 2364s # of utf8mb4 is: 2364s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2364s # - MySQL 8.0: utf8mb4_0900_ai_ci 2364s # 2364s # Reference: 2364s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2364s # - https://github.com/wagtail/wagtail/issues/9477 2364s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2364s self.set_character_set(self.charset, self.collation) 2364s 2364s if self.sql_mode is not None: 2364s c = self.cursor() 2364s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2364s c.close() 2364s 2364s if self.init_command is not None: 2364s c = self.cursor() 2364s c.execute(self.init_command) 2364s c.close() 2364s 2364s if self.autocommit_mode is not None: 2364s self.autocommit(self.autocommit_mode) 2364s except BaseException as e: 2364s self._rfile = None 2364s if sock is not None: 2364s try: 2364s sock.close() 2364s except: # noqa 2364s pass 2364s 2364s if isinstance(e, (OSError, IOError)): 2364s exc = err.OperationalError( 2364s CR.CR_CONN_HOST_ERROR, 2364s f"Can't connect to MySQL server on {self.host!r} ({e})", 2364s ) 2364s # Keep original exception and traceback to investigate error. 2364s exc.original_exception = e 2364s exc.traceback = traceback.format_exc() 2364s if DEBUG: 2364s print(exc.traceback) 2364s > raise exc 2364s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2364s 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2364s 2364s The above exception was the direct cause of the following exception: 2364s 2364s @pytest.fixture 2364s def mysql_pymysql_engine(): 2364s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2364s pymysql = td.versioned_importorskip("pymysql") 2364s engine = sqlalchemy.create_engine( 2364s "mysql+pymysql://root@localhost:3306/pandas", 2364s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2364s poolclass=sqlalchemy.pool.NullPool, 2364s ) 2364s yield engine 2364s > for view in get_all_views(engine): 2364s 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2364s return inspect(conn).get_view_names() 2364s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2364s ret = reg(subject) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2364s return Inspector._construct(Inspector._init_engine, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2364s init(self, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2364s engine.connect().close() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2364s return self._connection_cls(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2364s Connection._handle_dbapi_exception_noconnection( 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2364s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2364s self._dbapi_connection = engine.raw_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2364s self.connect() 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s self = , sock = None 2364s 2364s def connect(self, sock=None): 2364s self._closed = False 2364s try: 2364s if sock is None: 2364s if self.unix_socket: 2364s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2364s sock.settimeout(self.connect_timeout) 2364s sock.connect(self.unix_socket) 2364s self.host_info = "Localhost via UNIX socket" 2364s self._secure = True 2364s if DEBUG: 2364s print("connected using unix_socket") 2364s else: 2364s kwargs = {} 2364s if self.bind_address is not None: 2364s kwargs["source_address"] = (self.bind_address, 0) 2364s while True: 2364s try: 2364s sock = socket.create_connection( 2364s (self.host, self.port), self.connect_timeout, **kwargs 2364s ) 2364s break 2364s except OSError as e: 2364s if e.errno == errno.EINTR: 2364s continue 2364s raise 2364s self.host_info = "socket %s:%d" % (self.host, self.port) 2364s if DEBUG: 2364s print("connected using socket") 2364s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2364s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2364s sock.settimeout(None) 2364s 2364s self._sock = sock 2364s self._rfile = sock.makefile("rb") 2364s self._next_seq_id = 0 2364s 2364s self._get_server_information() 2364s self._request_authentication() 2364s 2364s # Send "SET NAMES" query on init for: 2364s # - Ensure charaset (and collation) is set to the server. 2364s # - collation_id in handshake packet may be ignored. 2364s # - If collation is not specified, we don't know what is server's 2364s # default collation for the charset. For example, default collation 2364s # of utf8mb4 is: 2364s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2364s # - MySQL 8.0: utf8mb4_0900_ai_ci 2364s # 2364s # Reference: 2364s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2364s # - https://github.com/wagtail/wagtail/issues/9477 2364s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2364s self.set_character_set(self.charset, self.collation) 2364s 2364s if self.sql_mode is not None: 2364s c = self.cursor() 2364s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2364s c.close() 2364s 2364s if self.init_command is not None: 2364s c = self.cursor() 2364s c.execute(self.init_command) 2364s c.close() 2364s 2364s if self.autocommit_mode is not None: 2364s self.autocommit(self.autocommit_mode) 2364s except BaseException as e: 2364s self._rfile = None 2364s if sock is not None: 2364s try: 2364s sock.close() 2364s except: # noqa 2364s pass 2364s 2364s if isinstance(e, (OSError, IOError)): 2364s exc = err.OperationalError( 2364s CR.CR_CONN_HOST_ERROR, 2364s f"Can't connect to MySQL server on {self.host!r} ({e})", 2364s ) 2364s # Keep original exception and traceback to investigate error. 2364s exc.original_exception = e 2364s exc.traceback = traceback.format_exc() 2364s if DEBUG: 2364s print(exc.traceback) 2364s > raise exc 2364s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2364s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2364s 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2364s __________ ERROR at teardown of test_to_sql[None-mysql_pymysql_conn] ___________ 2364s self = , sock = None 2364s 2364s def connect(self, sock=None): 2364s self._closed = False 2364s try: 2364s if sock is None: 2364s if self.unix_socket: 2364s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2364s sock.settimeout(self.connect_timeout) 2364s sock.connect(self.unix_socket) 2364s self.host_info = "Localhost via UNIX socket" 2364s self._secure = True 2364s if DEBUG: 2364s print("connected using unix_socket") 2364s else: 2364s kwargs = {} 2364s if self.bind_address is not None: 2364s kwargs["source_address"] = (self.bind_address, 0) 2364s while True: 2364s try: 2364s > sock = socket.create_connection( 2364s (self.host, self.port), self.connect_timeout, **kwargs 2364s ) 2364s 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3.13/socket.py:864: in create_connection 2364s raise exceptions[0] 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s address = ('localhost', 3306), timeout = 10, source_address = None 2364s 2364s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2364s source_address=None, *, all_errors=False): 2364s """Connect to *address* and return the socket object. 2364s 2364s Convenience function. Connect to *address* (a 2-tuple ``(host, 2364s port)``) and return the socket object. Passing the optional 2364s *timeout* parameter will set the timeout on the socket instance 2364s before attempting to connect. If no *timeout* is supplied, the 2364s global default timeout setting returned by :func:`getdefaulttimeout` 2364s is used. If *source_address* is set it must be a tuple of (host, port) 2364s for the socket to bind as a source address before making the connection. 2364s A host of '' or port 0 tells the OS to use the default. When a connection 2364s cannot be created, raises the last error if *all_errors* is False, 2364s and an ExceptionGroup of all errors if *all_errors* is True. 2364s """ 2364s 2364s host, port = address 2364s exceptions = [] 2364s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2364s af, socktype, proto, canonname, sa = res 2364s sock = None 2364s try: 2364s sock = socket(af, socktype, proto) 2364s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2364s sock.settimeout(timeout) 2364s if source_address: 2364s sock.bind(source_address) 2364s > sock.connect(sa) 2364s E ConnectionRefusedError: [Errno 111] Connection refused 2364s 2364s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2364s 2364s During handling of the above exception, another exception occurred: 2364s 2364s self = 2364s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2364s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2364s 2364s def __init__( 2364s self, 2364s engine: Engine, 2364s connection: Optional[PoolProxiedConnection] = None, 2364s _has_events: Optional[bool] = None, 2364s _allow_revalidate: bool = True, 2364s _allow_autobegin: bool = True, 2364s ): 2364s """Construct a new Connection.""" 2364s self.engine = engine 2364s self.dialect = dialect = engine.dialect 2364s 2364s if connection is None: 2364s try: 2364s > self._dbapi_connection = engine.raw_connection() 2364s 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2364s self.connect() 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s self = , sock = None 2364s 2364s def connect(self, sock=None): 2364s self._closed = False 2364s try: 2364s if sock is None: 2364s if self.unix_socket: 2364s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2364s sock.settimeout(self.connect_timeout) 2364s sock.connect(self.unix_socket) 2364s self.host_info = "Localhost via UNIX socket" 2364s self._secure = True 2364s if DEBUG: 2364s print("connected using unix_socket") 2364s else: 2364s kwargs = {} 2364s if self.bind_address is not None: 2364s kwargs["source_address"] = (self.bind_address, 0) 2364s while True: 2364s try: 2364s sock = socket.create_connection( 2364s (self.host, self.port), self.connect_timeout, **kwargs 2364s ) 2364s break 2364s except OSError as e: 2364s if e.errno == errno.EINTR: 2364s continue 2364s raise 2364s self.host_info = "socket %s:%d" % (self.host, self.port) 2364s if DEBUG: 2364s print("connected using socket") 2364s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2364s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2364s sock.settimeout(None) 2364s 2364s self._sock = sock 2364s self._rfile = sock.makefile("rb") 2364s self._next_seq_id = 0 2364s 2364s self._get_server_information() 2364s self._request_authentication() 2364s 2364s # Send "SET NAMES" query on init for: 2364s # - Ensure charaset (and collation) is set to the server. 2364s # - collation_id in handshake packet may be ignored. 2364s # - If collation is not specified, we don't know what is server's 2364s # default collation for the charset. For example, default collation 2364s # of utf8mb4 is: 2364s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2364s # - MySQL 8.0: utf8mb4_0900_ai_ci 2364s # 2364s # Reference: 2364s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2364s # - https://github.com/wagtail/wagtail/issues/9477 2364s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2364s self.set_character_set(self.charset, self.collation) 2364s 2364s if self.sql_mode is not None: 2364s c = self.cursor() 2364s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2364s c.close() 2364s 2364s if self.init_command is not None: 2364s c = self.cursor() 2364s c.execute(self.init_command) 2364s c.close() 2364s 2364s if self.autocommit_mode is not None: 2364s self.autocommit(self.autocommit_mode) 2364s except BaseException as e: 2364s self._rfile = None 2364s if sock is not None: 2364s try: 2364s sock.close() 2364s except: # noqa 2364s pass 2364s 2364s if isinstance(e, (OSError, IOError)): 2364s exc = err.OperationalError( 2364s CR.CR_CONN_HOST_ERROR, 2364s f"Can't connect to MySQL server on {self.host!r} ({e})", 2364s ) 2364s # Keep original exception and traceback to investigate error. 2364s exc.original_exception = e 2364s exc.traceback = traceback.format_exc() 2364s if DEBUG: 2364s print(exc.traceback) 2364s > raise exc 2364s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2364s 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2364s 2364s The above exception was the direct cause of the following exception: 2364s 2364s @pytest.fixture 2364s def mysql_pymysql_engine(): 2364s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2364s pymysql = td.versioned_importorskip("pymysql") 2364s engine = sqlalchemy.create_engine( 2364s "mysql+pymysql://root@localhost:3306/pandas", 2364s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2364s poolclass=sqlalchemy.pool.NullPool, 2364s ) 2364s yield engine 2364s > for view in get_all_views(engine): 2364s 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2364s return inspect(conn).get_view_names() 2364s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2364s ret = reg(subject) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2364s return Inspector._construct(Inspector._init_engine, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2364s init(self, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2364s engine.connect().close() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2364s return self._connection_cls(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2364s Connection._handle_dbapi_exception_noconnection( 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2364s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2364s self._dbapi_connection = engine.raw_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2364s self.connect() 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s self = , sock = None 2364s 2364s def connect(self, sock=None): 2364s self._closed = False 2364s try: 2364s if sock is None: 2364s if self.unix_socket: 2364s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2364s sock.settimeout(self.connect_timeout) 2364s sock.connect(self.unix_socket) 2364s self.host_info = "Localhost via UNIX socket" 2364s self._secure = True 2364s if DEBUG: 2364s print("connected using unix_socket") 2364s else: 2364s kwargs = {} 2364s if self.bind_address is not None: 2364s kwargs["source_address"] = (self.bind_address, 0) 2364s while True: 2364s try: 2364s sock = socket.create_connection( 2364s (self.host, self.port), self.connect_timeout, **kwargs 2364s ) 2364s break 2364s except OSError as e: 2364s if e.errno == errno.EINTR: 2364s continue 2364s raise 2364s self.host_info = "socket %s:%d" % (self.host, self.port) 2364s if DEBUG: 2364s print("connected using socket") 2364s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2364s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2364s sock.settimeout(None) 2364s 2364s self._sock = sock 2364s self._rfile = sock.makefile("rb") 2364s self._next_seq_id = 0 2364s 2364s self._get_server_information() 2364s self._request_authentication() 2364s 2364s # Send "SET NAMES" query on init for: 2364s # - Ensure charaset (and collation) is set to the server. 2364s # - collation_id in handshake packet may be ignored. 2364s # - If collation is not specified, we don't know what is server's 2364s # default collation for the charset. For example, default collation 2364s # of utf8mb4 is: 2364s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2364s # - MySQL 8.0: utf8mb4_0900_ai_ci 2364s # 2364s # Reference: 2364s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2364s # - https://github.com/wagtail/wagtail/issues/9477 2364s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2364s self.set_character_set(self.charset, self.collation) 2364s 2364s if self.sql_mode is not None: 2364s c = self.cursor() 2364s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2364s c.close() 2364s 2364s if self.init_command is not None: 2364s c = self.cursor() 2364s c.execute(self.init_command) 2364s c.close() 2364s 2364s if self.autocommit_mode is not None: 2364s self.autocommit(self.autocommit_mode) 2364s except BaseException as e: 2364s self._rfile = None 2364s if sock is not None: 2364s try: 2364s sock.close() 2364s except: # noqa 2364s pass 2364s 2364s if isinstance(e, (OSError, IOError)): 2364s exc = err.OperationalError( 2364s CR.CR_CONN_HOST_ERROR, 2364s f"Can't connect to MySQL server on {self.host!r} ({e})", 2364s ) 2364s # Keep original exception and traceback to investigate error. 2364s exc.original_exception = e 2364s exc.traceback = traceback.format_exc() 2364s if DEBUG: 2364s print(exc.traceback) 2364s > raise exc 2364s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2364s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2364s 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2364s ______ ERROR at teardown of test_to_sql[None-postgresql_psycopg2_engine] _______ 2364s self = 2364s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2364s connection = None, _has_events = None, _allow_revalidate = True 2364s _allow_autobegin = True 2364s 2364s def __init__( 2364s self, 2364s engine: Engine, 2364s connection: Optional[PoolProxiedConnection] = None, 2364s _has_events: Optional[bool] = None, 2364s _allow_revalidate: bool = True, 2364s _allow_autobegin: bool = True, 2364s ): 2364s """Construct a new Connection.""" 2364s self.engine = engine 2364s self.dialect = dialect = engine.dialect 2364s 2364s if connection is None: 2364s try: 2364s > self._dbapi_connection = engine.raw_connection() 2364s 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2364s connection_factory = None, cursor_factory = None 2364s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2364s kwasync = {} 2364s 2364s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2364s """ 2364s Create a new database connection. 2364s 2364s The connection parameters can be specified as a string: 2364s 2364s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2364s 2364s or using a set of keyword arguments: 2364s 2364s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2364s 2364s Or as a mix of both. The basic connection parameters are: 2364s 2364s - *dbname*: the database name 2364s - *database*: the database name (only as keyword argument) 2364s - *user*: user name used to authenticate 2364s - *password*: password used to authenticate 2364s - *host*: database host address (defaults to UNIX socket if not provided) 2364s - *port*: connection port number (defaults to 5432 if not provided) 2364s 2364s Using the *connection_factory* parameter a different class or connections 2364s factory can be specified. It should be a callable object taking a dsn 2364s argument. 2364s 2364s Using the *cursor_factory* parameter, a new default cursor factory will be 2364s used by cursor(). 2364s 2364s Using *async*=True an asynchronous connection will be created. *async_* is 2364s a valid alias (for Python versions where ``async`` is a keyword). 2364s 2364s Any other keyword parameter will be passed to the underlying client 2364s library: the list of supported parameters depends on the library version. 2364s 2364s """ 2364s kwasync = {} 2364s if 'async' in kwargs: 2364s kwasync['async'] = kwargs.pop('async') 2364s if 'async_' in kwargs: 2364s kwasync['async_'] = kwargs.pop('async_') 2364s 2364s dsn = _ext.make_dsn(dsn, **kwargs) 2364s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2364s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s 2364s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2364s 2364s The above exception was the direct cause of the following exception: 2364s 2364s @pytest.fixture 2364s def postgresql_psycopg2_engine(): 2364s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2364s td.versioned_importorskip("psycopg2") 2364s engine = sqlalchemy.create_engine( 2364s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2364s poolclass=sqlalchemy.pool.NullPool, 2364s ) 2364s yield engine 2364s > for view in get_all_views(engine): 2364s 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2364s return inspect(conn).get_view_names() 2364s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2364s ret = reg(subject) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2364s return Inspector._construct(Inspector._init_engine, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2364s init(self, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2364s engine.connect().close() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2364s return self._connection_cls(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2364s Connection._handle_dbapi_exception_noconnection( 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2364s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2364s self._dbapi_connection = engine.raw_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2364s connection_factory = None, cursor_factory = None 2364s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2364s kwasync = {} 2364s 2364s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2364s """ 2364s Create a new database connection. 2364s 2364s The connection parameters can be specified as a string: 2364s 2364s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2364s 2364s or using a set of keyword arguments: 2364s 2364s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2364s 2364s Or as a mix of both. The basic connection parameters are: 2364s 2364s - *dbname*: the database name 2364s - *database*: the database name (only as keyword argument) 2364s - *user*: user name used to authenticate 2364s - *password*: password used to authenticate 2364s - *host*: database host address (defaults to UNIX socket if not provided) 2364s - *port*: connection port number (defaults to 5432 if not provided) 2364s 2364s Using the *connection_factory* parameter a different class or connections 2364s factory can be specified. It should be a callable object taking a dsn 2364s argument. 2364s 2364s Using the *cursor_factory* parameter, a new default cursor factory will be 2364s used by cursor(). 2364s 2364s Using *async*=True an asynchronous connection will be created. *async_* is 2364s a valid alias (for Python versions where ``async`` is a keyword). 2364s 2364s Any other keyword parameter will be passed to the underlying client 2364s library: the list of supported parameters depends on the library version. 2364s 2364s """ 2364s kwasync = {} 2364s if 'async' in kwargs: 2364s kwasync['async'] = kwargs.pop('async') 2364s if 'async_' in kwargs: 2364s kwasync['async_'] = kwargs.pop('async_') 2364s 2364s dsn = _ext.make_dsn(dsn, **kwargs) 2364s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2364s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s E 2364s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2364s 2364s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2364s _______ ERROR at teardown of test_to_sql[None-postgresql_psycopg2_conn] ________ 2364s self = 2364s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2364s connection = None, _has_events = None, _allow_revalidate = True 2364s _allow_autobegin = True 2364s 2364s def __init__( 2364s self, 2364s engine: Engine, 2364s connection: Optional[PoolProxiedConnection] = None, 2364s _has_events: Optional[bool] = None, 2364s _allow_revalidate: bool = True, 2364s _allow_autobegin: bool = True, 2364s ): 2364s """Construct a new Connection.""" 2364s self.engine = engine 2364s self.dialect = dialect = engine.dialect 2364s 2364s if connection is None: 2364s try: 2364s > self._dbapi_connection = engine.raw_connection() 2364s 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2364s connection_factory = None, cursor_factory = None 2364s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2364s kwasync = {} 2364s 2364s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2364s """ 2364s Create a new database connection. 2364s 2364s The connection parameters can be specified as a string: 2364s 2364s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2364s 2364s or using a set of keyword arguments: 2364s 2364s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2364s 2364s Or as a mix of both. The basic connection parameters are: 2364s 2364s - *dbname*: the database name 2364s - *database*: the database name (only as keyword argument) 2364s - *user*: user name used to authenticate 2364s - *password*: password used to authenticate 2364s - *host*: database host address (defaults to UNIX socket if not provided) 2364s - *port*: connection port number (defaults to 5432 if not provided) 2364s 2364s Using the *connection_factory* parameter a different class or connections 2364s factory can be specified. It should be a callable object taking a dsn 2364s argument. 2364s 2364s Using the *cursor_factory* parameter, a new default cursor factory will be 2364s used by cursor(). 2364s 2364s Using *async*=True an asynchronous connection will be created. *async_* is 2364s a valid alias (for Python versions where ``async`` is a keyword). 2364s 2364s Any other keyword parameter will be passed to the underlying client 2364s library: the list of supported parameters depends on the library version. 2364s 2364s """ 2364s kwasync = {} 2364s if 'async' in kwargs: 2364s kwasync['async'] = kwargs.pop('async') 2364s if 'async_' in kwargs: 2364s kwasync['async_'] = kwargs.pop('async_') 2364s 2364s dsn = _ext.make_dsn(dsn, **kwargs) 2364s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2364s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s 2364s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2364s 2364s The above exception was the direct cause of the following exception: 2364s 2364s @pytest.fixture 2364s def postgresql_psycopg2_engine(): 2364s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2364s td.versioned_importorskip("psycopg2") 2364s engine = sqlalchemy.create_engine( 2364s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2364s poolclass=sqlalchemy.pool.NullPool, 2364s ) 2364s yield engine 2364s > for view in get_all_views(engine): 2364s 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2364s return inspect(conn).get_view_names() 2364s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2364s ret = reg(subject) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2364s return Inspector._construct(Inspector._init_engine, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2364s init(self, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2364s engine.connect().close() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2364s return self._connection_cls(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2364s Connection._handle_dbapi_exception_noconnection( 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2364s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2364s self._dbapi_connection = engine.raw_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2364s connection_factory = None, cursor_factory = None 2364s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2364s kwasync = {} 2364s 2364s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2364s """ 2364s Create a new database connection. 2364s 2364s The connection parameters can be specified as a string: 2364s 2364s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2364s 2364s or using a set of keyword arguments: 2364s 2364s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2364s 2364s Or as a mix of both. The basic connection parameters are: 2364s 2364s - *dbname*: the database name 2364s - *database*: the database name (only as keyword argument) 2364s - *user*: user name used to authenticate 2364s - *password*: password used to authenticate 2364s - *host*: database host address (defaults to UNIX socket if not provided) 2364s - *port*: connection port number (defaults to 5432 if not provided) 2364s 2364s Using the *connection_factory* parameter a different class or connections 2364s factory can be specified. It should be a callable object taking a dsn 2364s argument. 2364s 2364s Using the *cursor_factory* parameter, a new default cursor factory will be 2364s used by cursor(). 2364s 2364s Using *async*=True an asynchronous connection will be created. *async_* is 2364s a valid alias (for Python versions where ``async`` is a keyword). 2364s 2364s Any other keyword parameter will be passed to the underlying client 2364s library: the list of supported parameters depends on the library version. 2364s 2364s """ 2364s kwasync = {} 2364s if 'async' in kwargs: 2364s kwasync['async'] = kwargs.pop('async') 2364s if 'async_' in kwargs: 2364s kwasync['async_'] = kwargs.pop('async_') 2364s 2364s dsn = _ext.make_dsn(dsn, **kwargs) 2364s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2364s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s E 2364s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2364s 2364s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2364s _________ ERROR at teardown of test_to_sql[multi-mysql_pymysql_engine] _________ 2364s self = , sock = None 2364s 2364s def connect(self, sock=None): 2364s self._closed = False 2364s try: 2364s if sock is None: 2364s if self.unix_socket: 2364s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2364s sock.settimeout(self.connect_timeout) 2364s sock.connect(self.unix_socket) 2364s self.host_info = "Localhost via UNIX socket" 2364s self._secure = True 2364s if DEBUG: 2364s print("connected using unix_socket") 2364s else: 2364s kwargs = {} 2364s if self.bind_address is not None: 2364s kwargs["source_address"] = (self.bind_address, 0) 2364s while True: 2364s try: 2364s > sock = socket.create_connection( 2364s (self.host, self.port), self.connect_timeout, **kwargs 2364s ) 2364s 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3.13/socket.py:864: in create_connection 2364s raise exceptions[0] 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s address = ('localhost', 3306), timeout = 10, source_address = None 2364s 2364s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2364s source_address=None, *, all_errors=False): 2364s """Connect to *address* and return the socket object. 2364s 2364s Convenience function. Connect to *address* (a 2-tuple ``(host, 2364s port)``) and return the socket object. Passing the optional 2364s *timeout* parameter will set the timeout on the socket instance 2364s before attempting to connect. If no *timeout* is supplied, the 2364s global default timeout setting returned by :func:`getdefaulttimeout` 2364s is used. If *source_address* is set it must be a tuple of (host, port) 2364s for the socket to bind as a source address before making the connection. 2364s A host of '' or port 0 tells the OS to use the default. When a connection 2364s cannot be created, raises the last error if *all_errors* is False, 2364s and an ExceptionGroup of all errors if *all_errors* is True. 2364s """ 2364s 2364s host, port = address 2364s exceptions = [] 2364s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2364s af, socktype, proto, canonname, sa = res 2364s sock = None 2364s try: 2364s sock = socket(af, socktype, proto) 2364s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2364s sock.settimeout(timeout) 2364s if source_address: 2364s sock.bind(source_address) 2364s > sock.connect(sa) 2364s E ConnectionRefusedError: [Errno 111] Connection refused 2364s 2364s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2364s 2364s During handling of the above exception, another exception occurred: 2364s 2364s self = 2364s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2364s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2364s 2364s def __init__( 2364s self, 2364s engine: Engine, 2364s connection: Optional[PoolProxiedConnection] = None, 2364s _has_events: Optional[bool] = None, 2364s _allow_revalidate: bool = True, 2364s _allow_autobegin: bool = True, 2364s ): 2364s """Construct a new Connection.""" 2364s self.engine = engine 2364s self.dialect = dialect = engine.dialect 2364s 2364s if connection is None: 2364s try: 2364s > self._dbapi_connection = engine.raw_connection() 2364s 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2364s self.connect() 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s self = , sock = None 2364s 2364s def connect(self, sock=None): 2364s self._closed = False 2364s try: 2364s if sock is None: 2364s if self.unix_socket: 2364s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2364s sock.settimeout(self.connect_timeout) 2364s sock.connect(self.unix_socket) 2364s self.host_info = "Localhost via UNIX socket" 2364s self._secure = True 2364s if DEBUG: 2364s print("connected using unix_socket") 2364s else: 2364s kwargs = {} 2364s if self.bind_address is not None: 2364s kwargs["source_address"] = (self.bind_address, 0) 2364s while True: 2364s try: 2364s sock = socket.create_connection( 2364s (self.host, self.port), self.connect_timeout, **kwargs 2364s ) 2364s break 2364s except OSError as e: 2364s if e.errno == errno.EINTR: 2364s continue 2364s raise 2364s self.host_info = "socket %s:%d" % (self.host, self.port) 2364s if DEBUG: 2364s print("connected using socket") 2364s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2364s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2364s sock.settimeout(None) 2364s 2364s self._sock = sock 2364s self._rfile = sock.makefile("rb") 2364s self._next_seq_id = 0 2364s 2364s self._get_server_information() 2364s self._request_authentication() 2364s 2364s # Send "SET NAMES" query on init for: 2364s # - Ensure charaset (and collation) is set to the server. 2364s # - collation_id in handshake packet may be ignored. 2364s # - If collation is not specified, we don't know what is server's 2364s # default collation for the charset. For example, default collation 2364s # of utf8mb4 is: 2364s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2364s # - MySQL 8.0: utf8mb4_0900_ai_ci 2364s # 2364s # Reference: 2364s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2364s # - https://github.com/wagtail/wagtail/issues/9477 2364s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2364s self.set_character_set(self.charset, self.collation) 2364s 2364s if self.sql_mode is not None: 2364s c = self.cursor() 2364s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2364s c.close() 2364s 2364s if self.init_command is not None: 2364s c = self.cursor() 2364s c.execute(self.init_command) 2364s c.close() 2364s 2364s if self.autocommit_mode is not None: 2364s self.autocommit(self.autocommit_mode) 2364s except BaseException as e: 2364s self._rfile = None 2364s if sock is not None: 2364s try: 2364s sock.close() 2364s except: # noqa 2364s pass 2364s 2364s if isinstance(e, (OSError, IOError)): 2364s exc = err.OperationalError( 2364s CR.CR_CONN_HOST_ERROR, 2364s f"Can't connect to MySQL server on {self.host!r} ({e})", 2364s ) 2364s # Keep original exception and traceback to investigate error. 2364s exc.original_exception = e 2364s exc.traceback = traceback.format_exc() 2364s if DEBUG: 2364s print(exc.traceback) 2364s > raise exc 2364s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2364s 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2364s 2364s The above exception was the direct cause of the following exception: 2364s 2364s @pytest.fixture 2364s def mysql_pymysql_engine(): 2364s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2364s pymysql = td.versioned_importorskip("pymysql") 2364s engine = sqlalchemy.create_engine( 2364s "mysql+pymysql://root@localhost:3306/pandas", 2364s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2364s poolclass=sqlalchemy.pool.NullPool, 2364s ) 2364s yield engine 2364s > for view in get_all_views(engine): 2364s 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2364s return inspect(conn).get_view_names() 2364s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2364s ret = reg(subject) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2364s return Inspector._construct(Inspector._init_engine, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2364s init(self, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2364s engine.connect().close() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2364s return self._connection_cls(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2364s Connection._handle_dbapi_exception_noconnection( 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2364s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2364s self._dbapi_connection = engine.raw_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2364s self.connect() 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s self = , sock = None 2364s 2364s def connect(self, sock=None): 2364s self._closed = False 2364s try: 2364s if sock is None: 2364s if self.unix_socket: 2364s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2364s sock.settimeout(self.connect_timeout) 2364s sock.connect(self.unix_socket) 2364s self.host_info = "Localhost via UNIX socket" 2364s self._secure = True 2364s if DEBUG: 2364s print("connected using unix_socket") 2364s else: 2364s kwargs = {} 2364s if self.bind_address is not None: 2364s kwargs["source_address"] = (self.bind_address, 0) 2364s while True: 2364s try: 2364s sock = socket.create_connection( 2364s (self.host, self.port), self.connect_timeout, **kwargs 2364s ) 2364s break 2364s except OSError as e: 2364s if e.errno == errno.EINTR: 2364s continue 2364s raise 2364s self.host_info = "socket %s:%d" % (self.host, self.port) 2364s if DEBUG: 2364s print("connected using socket") 2364s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2364s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2364s sock.settimeout(None) 2364s 2364s self._sock = sock 2364s self._rfile = sock.makefile("rb") 2364s self._next_seq_id = 0 2364s 2364s self._get_server_information() 2364s self._request_authentication() 2364s 2364s # Send "SET NAMES" query on init for: 2364s # - Ensure charaset (and collation) is set to the server. 2364s # - collation_id in handshake packet may be ignored. 2364s # - If collation is not specified, we don't know what is server's 2364s # default collation for the charset. For example, default collation 2364s # of utf8mb4 is: 2364s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2364s # - MySQL 8.0: utf8mb4_0900_ai_ci 2364s # 2364s # Reference: 2364s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2364s # - https://github.com/wagtail/wagtail/issues/9477 2364s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2364s self.set_character_set(self.charset, self.collation) 2364s 2364s if self.sql_mode is not None: 2364s c = self.cursor() 2364s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2364s c.close() 2364s 2364s if self.init_command is not None: 2364s c = self.cursor() 2364s c.execute(self.init_command) 2364s c.close() 2364s 2364s if self.autocommit_mode is not None: 2364s self.autocommit(self.autocommit_mode) 2364s except BaseException as e: 2364s self._rfile = None 2364s if sock is not None: 2364s try: 2364s sock.close() 2364s except: # noqa 2364s pass 2364s 2364s if isinstance(e, (OSError, IOError)): 2364s exc = err.OperationalError( 2364s CR.CR_CONN_HOST_ERROR, 2364s f"Can't connect to MySQL server on {self.host!r} ({e})", 2364s ) 2364s # Keep original exception and traceback to investigate error. 2364s exc.original_exception = e 2364s exc.traceback = traceback.format_exc() 2364s if DEBUG: 2364s print(exc.traceback) 2364s > raise exc 2364s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2364s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2364s 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2364s __________ ERROR at teardown of test_to_sql[multi-mysql_pymysql_conn] __________ 2364s self = , sock = None 2364s 2364s def connect(self, sock=None): 2364s self._closed = False 2364s try: 2364s if sock is None: 2364s if self.unix_socket: 2364s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2364s sock.settimeout(self.connect_timeout) 2364s sock.connect(self.unix_socket) 2364s self.host_info = "Localhost via UNIX socket" 2364s self._secure = True 2364s if DEBUG: 2364s print("connected using unix_socket") 2364s else: 2364s kwargs = {} 2364s if self.bind_address is not None: 2364s kwargs["source_address"] = (self.bind_address, 0) 2364s while True: 2364s try: 2364s > sock = socket.create_connection( 2364s (self.host, self.port), self.connect_timeout, **kwargs 2364s ) 2364s 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3.13/socket.py:864: in create_connection 2364s raise exceptions[0] 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s address = ('localhost', 3306), timeout = 10, source_address = None 2364s 2364s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2364s source_address=None, *, all_errors=False): 2364s """Connect to *address* and return the socket object. 2364s 2364s Convenience function. Connect to *address* (a 2-tuple ``(host, 2364s port)``) and return the socket object. Passing the optional 2364s *timeout* parameter will set the timeout on the socket instance 2364s before attempting to connect. If no *timeout* is supplied, the 2364s global default timeout setting returned by :func:`getdefaulttimeout` 2364s is used. If *source_address* is set it must be a tuple of (host, port) 2364s for the socket to bind as a source address before making the connection. 2364s A host of '' or port 0 tells the OS to use the default. When a connection 2364s cannot be created, raises the last error if *all_errors* is False, 2364s and an ExceptionGroup of all errors if *all_errors* is True. 2364s """ 2364s 2364s host, port = address 2364s exceptions = [] 2364s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2364s af, socktype, proto, canonname, sa = res 2364s sock = None 2364s try: 2364s sock = socket(af, socktype, proto) 2364s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2364s sock.settimeout(timeout) 2364s if source_address: 2364s sock.bind(source_address) 2364s > sock.connect(sa) 2364s E ConnectionRefusedError: [Errno 111] Connection refused 2364s 2364s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2364s 2364s During handling of the above exception, another exception occurred: 2364s 2364s self = 2364s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2364s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2364s 2364s def __init__( 2364s self, 2364s engine: Engine, 2364s connection: Optional[PoolProxiedConnection] = None, 2364s _has_events: Optional[bool] = None, 2364s _allow_revalidate: bool = True, 2364s _allow_autobegin: bool = True, 2364s ): 2364s """Construct a new Connection.""" 2364s self.engine = engine 2364s self.dialect = dialect = engine.dialect 2364s 2364s if connection is None: 2364s try: 2364s > self._dbapi_connection = engine.raw_connection() 2364s 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2364s self.connect() 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s self = , sock = None 2364s 2364s def connect(self, sock=None): 2364s self._closed = False 2364s try: 2364s if sock is None: 2364s if self.unix_socket: 2364s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2364s sock.settimeout(self.connect_timeout) 2364s sock.connect(self.unix_socket) 2364s self.host_info = "Localhost via UNIX socket" 2364s self._secure = True 2364s if DEBUG: 2364s print("connected using unix_socket") 2364s else: 2364s kwargs = {} 2364s if self.bind_address is not None: 2364s kwargs["source_address"] = (self.bind_address, 0) 2364s while True: 2364s try: 2364s sock = socket.create_connection( 2364s (self.host, self.port), self.connect_timeout, **kwargs 2364s ) 2364s break 2364s except OSError as e: 2364s if e.errno == errno.EINTR: 2364s continue 2364s raise 2364s self.host_info = "socket %s:%d" % (self.host, self.port) 2364s if DEBUG: 2364s print("connected using socket") 2364s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2364s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2364s sock.settimeout(None) 2364s 2364s self._sock = sock 2364s self._rfile = sock.makefile("rb") 2364s self._next_seq_id = 0 2364s 2364s self._get_server_information() 2364s self._request_authentication() 2364s 2364s # Send "SET NAMES" query on init for: 2364s # - Ensure charaset (and collation) is set to the server. 2364s # - collation_id in handshake packet may be ignored. 2364s # - If collation is not specified, we don't know what is server's 2364s # default collation for the charset. For example, default collation 2364s # of utf8mb4 is: 2364s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2364s # - MySQL 8.0: utf8mb4_0900_ai_ci 2364s # 2364s # Reference: 2364s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2364s # - https://github.com/wagtail/wagtail/issues/9477 2364s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2364s self.set_character_set(self.charset, self.collation) 2364s 2364s if self.sql_mode is not None: 2364s c = self.cursor() 2364s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2364s c.close() 2364s 2364s if self.init_command is not None: 2364s c = self.cursor() 2364s c.execute(self.init_command) 2364s c.close() 2364s 2364s if self.autocommit_mode is not None: 2364s self.autocommit(self.autocommit_mode) 2364s except BaseException as e: 2364s self._rfile = None 2364s if sock is not None: 2364s try: 2364s sock.close() 2364s except: # noqa 2364s pass 2364s 2364s if isinstance(e, (OSError, IOError)): 2364s exc = err.OperationalError( 2364s CR.CR_CONN_HOST_ERROR, 2364s f"Can't connect to MySQL server on {self.host!r} ({e})", 2364s ) 2364s # Keep original exception and traceback to investigate error. 2364s exc.original_exception = e 2364s exc.traceback = traceback.format_exc() 2364s if DEBUG: 2364s print(exc.traceback) 2364s > raise exc 2364s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2364s 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2364s 2364s The above exception was the direct cause of the following exception: 2364s 2364s @pytest.fixture 2364s def mysql_pymysql_engine(): 2364s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2364s pymysql = td.versioned_importorskip("pymysql") 2364s engine = sqlalchemy.create_engine( 2364s "mysql+pymysql://root@localhost:3306/pandas", 2364s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2364s poolclass=sqlalchemy.pool.NullPool, 2364s ) 2364s yield engine 2364s > for view in get_all_views(engine): 2364s 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2364s return inspect(conn).get_view_names() 2364s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2364s ret = reg(subject) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2364s return Inspector._construct(Inspector._init_engine, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2364s init(self, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2364s engine.connect().close() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2364s return self._connection_cls(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2364s Connection._handle_dbapi_exception_noconnection( 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2364s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2364s self._dbapi_connection = engine.raw_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2364s self.connect() 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s self = , sock = None 2364s 2364s def connect(self, sock=None): 2364s self._closed = False 2364s try: 2364s if sock is None: 2364s if self.unix_socket: 2364s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2364s sock.settimeout(self.connect_timeout) 2364s sock.connect(self.unix_socket) 2364s self.host_info = "Localhost via UNIX socket" 2364s self._secure = True 2364s if DEBUG: 2364s print("connected using unix_socket") 2364s else: 2364s kwargs = {} 2364s if self.bind_address is not None: 2364s kwargs["source_address"] = (self.bind_address, 0) 2364s while True: 2364s try: 2364s sock = socket.create_connection( 2364s (self.host, self.port), self.connect_timeout, **kwargs 2364s ) 2364s break 2364s except OSError as e: 2364s if e.errno == errno.EINTR: 2364s continue 2364s raise 2364s self.host_info = "socket %s:%d" % (self.host, self.port) 2364s if DEBUG: 2364s print("connected using socket") 2364s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2364s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2364s sock.settimeout(None) 2364s 2364s self._sock = sock 2364s self._rfile = sock.makefile("rb") 2364s self._next_seq_id = 0 2364s 2364s self._get_server_information() 2364s self._request_authentication() 2364s 2364s # Send "SET NAMES" query on init for: 2364s # - Ensure charaset (and collation) is set to the server. 2364s # - collation_id in handshake packet may be ignored. 2364s # - If collation is not specified, we don't know what is server's 2364s # default collation for the charset. For example, default collation 2364s # of utf8mb4 is: 2364s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2364s # - MySQL 8.0: utf8mb4_0900_ai_ci 2364s # 2364s # Reference: 2364s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2364s # - https://github.com/wagtail/wagtail/issues/9477 2364s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2364s self.set_character_set(self.charset, self.collation) 2364s 2364s if self.sql_mode is not None: 2364s c = self.cursor() 2364s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2364s c.close() 2364s 2364s if self.init_command is not None: 2364s c = self.cursor() 2364s c.execute(self.init_command) 2364s c.close() 2364s 2364s if self.autocommit_mode is not None: 2364s self.autocommit(self.autocommit_mode) 2364s except BaseException as e: 2364s self._rfile = None 2364s if sock is not None: 2364s try: 2364s sock.close() 2364s except: # noqa 2364s pass 2364s 2364s if isinstance(e, (OSError, IOError)): 2364s exc = err.OperationalError( 2364s CR.CR_CONN_HOST_ERROR, 2364s f"Can't connect to MySQL server on {self.host!r} ({e})", 2364s ) 2364s # Keep original exception and traceback to investigate error. 2364s exc.original_exception = e 2364s exc.traceback = traceback.format_exc() 2364s if DEBUG: 2364s print(exc.traceback) 2364s > raise exc 2364s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2364s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2364s 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2364s ______ ERROR at teardown of test_to_sql[multi-postgresql_psycopg2_engine] ______ 2364s self = 2364s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2364s connection = None, _has_events = None, _allow_revalidate = True 2364s _allow_autobegin = True 2364s 2364s def __init__( 2364s self, 2364s engine: Engine, 2364s connection: Optional[PoolProxiedConnection] = None, 2364s _has_events: Optional[bool] = None, 2364s _allow_revalidate: bool = True, 2364s _allow_autobegin: bool = True, 2364s ): 2364s """Construct a new Connection.""" 2364s self.engine = engine 2364s self.dialect = dialect = engine.dialect 2364s 2364s if connection is None: 2364s try: 2364s > self._dbapi_connection = engine.raw_connection() 2364s 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2364s connection_factory = None, cursor_factory = None 2364s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2364s kwasync = {} 2364s 2364s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2364s """ 2364s Create a new database connection. 2364s 2364s The connection parameters can be specified as a string: 2364s 2364s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2364s 2364s or using a set of keyword arguments: 2364s 2364s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2364s 2364s Or as a mix of both. The basic connection parameters are: 2364s 2364s - *dbname*: the database name 2364s - *database*: the database name (only as keyword argument) 2364s - *user*: user name used to authenticate 2364s - *password*: password used to authenticate 2364s - *host*: database host address (defaults to UNIX socket if not provided) 2364s - *port*: connection port number (defaults to 5432 if not provided) 2364s 2364s Using the *connection_factory* parameter a different class or connections 2364s factory can be specified. It should be a callable object taking a dsn 2364s argument. 2364s 2364s Using the *cursor_factory* parameter, a new default cursor factory will be 2364s used by cursor(). 2364s 2364s Using *async*=True an asynchronous connection will be created. *async_* is 2364s a valid alias (for Python versions where ``async`` is a keyword). 2364s 2364s Any other keyword parameter will be passed to the underlying client 2364s library: the list of supported parameters depends on the library version. 2364s 2364s """ 2364s kwasync = {} 2364s if 'async' in kwargs: 2364s kwasync['async'] = kwargs.pop('async') 2364s if 'async_' in kwargs: 2364s kwasync['async_'] = kwargs.pop('async_') 2364s 2364s dsn = _ext.make_dsn(dsn, **kwargs) 2364s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2364s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s 2364s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2364s 2364s The above exception was the direct cause of the following exception: 2364s 2364s @pytest.fixture 2364s def postgresql_psycopg2_engine(): 2364s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2364s td.versioned_importorskip("psycopg2") 2364s engine = sqlalchemy.create_engine( 2364s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2364s poolclass=sqlalchemy.pool.NullPool, 2364s ) 2364s yield engine 2364s > for view in get_all_views(engine): 2364s 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2364s return inspect(conn).get_view_names() 2364s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2364s ret = reg(subject) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2364s return Inspector._construct(Inspector._init_engine, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2364s init(self, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2364s engine.connect().close() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2364s return self._connection_cls(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2364s Connection._handle_dbapi_exception_noconnection( 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2364s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2364s self._dbapi_connection = engine.raw_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2364s connection_factory = None, cursor_factory = None 2364s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2364s kwasync = {} 2364s 2364s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2364s """ 2364s Create a new database connection. 2364s 2364s The connection parameters can be specified as a string: 2364s 2364s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2364s 2364s or using a set of keyword arguments: 2364s 2364s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2364s 2364s Or as a mix of both. The basic connection parameters are: 2364s 2364s - *dbname*: the database name 2364s - *database*: the database name (only as keyword argument) 2364s - *user*: user name used to authenticate 2364s - *password*: password used to authenticate 2364s - *host*: database host address (defaults to UNIX socket if not provided) 2364s - *port*: connection port number (defaults to 5432 if not provided) 2364s 2364s Using the *connection_factory* parameter a different class or connections 2364s factory can be specified. It should be a callable object taking a dsn 2364s argument. 2364s 2364s Using the *cursor_factory* parameter, a new default cursor factory will be 2364s used by cursor(). 2364s 2364s Using *async*=True an asynchronous connection will be created. *async_* is 2364s a valid alias (for Python versions where ``async`` is a keyword). 2364s 2364s Any other keyword parameter will be passed to the underlying client 2364s library: the list of supported parameters depends on the library version. 2364s 2364s """ 2364s kwasync = {} 2364s if 'async' in kwargs: 2364s kwasync['async'] = kwargs.pop('async') 2364s if 'async_' in kwargs: 2364s kwasync['async_'] = kwargs.pop('async_') 2364s 2364s dsn = _ext.make_dsn(dsn, **kwargs) 2364s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2364s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s E 2364s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2364s 2364s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2364s _______ ERROR at teardown of test_to_sql[multi-postgresql_psycopg2_conn] _______ 2364s self = 2364s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2364s connection = None, _has_events = None, _allow_revalidate = True 2364s _allow_autobegin = True 2364s 2364s def __init__( 2364s self, 2364s engine: Engine, 2364s connection: Optional[PoolProxiedConnection] = None, 2364s _has_events: Optional[bool] = None, 2364s _allow_revalidate: bool = True, 2364s _allow_autobegin: bool = True, 2364s ): 2364s """Construct a new Connection.""" 2364s self.engine = engine 2364s self.dialect = dialect = engine.dialect 2364s 2364s if connection is None: 2364s try: 2364s > self._dbapi_connection = engine.raw_connection() 2364s 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2364s connection_factory = None, cursor_factory = None 2364s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2364s kwasync = {} 2364s 2364s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2364s """ 2364s Create a new database connection. 2364s 2364s The connection parameters can be specified as a string: 2364s 2364s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2364s 2364s or using a set of keyword arguments: 2364s 2364s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2364s 2364s Or as a mix of both. The basic connection parameters are: 2364s 2364s - *dbname*: the database name 2364s - *database*: the database name (only as keyword argument) 2364s - *user*: user name used to authenticate 2364s - *password*: password used to authenticate 2364s - *host*: database host address (defaults to UNIX socket if not provided) 2364s - *port*: connection port number (defaults to 5432 if not provided) 2364s 2364s Using the *connection_factory* parameter a different class or connections 2364s factory can be specified. It should be a callable object taking a dsn 2364s argument. 2364s 2364s Using the *cursor_factory* parameter, a new default cursor factory will be 2364s used by cursor(). 2364s 2364s Using *async*=True an asynchronous connection will be created. *async_* is 2364s a valid alias (for Python versions where ``async`` is a keyword). 2364s 2364s Any other keyword parameter will be passed to the underlying client 2364s library: the list of supported parameters depends on the library version. 2364s 2364s """ 2364s kwasync = {} 2364s if 'async' in kwargs: 2364s kwasync['async'] = kwargs.pop('async') 2364s if 'async_' in kwargs: 2364s kwasync['async_'] = kwargs.pop('async_') 2364s 2364s dsn = _ext.make_dsn(dsn, **kwargs) 2364s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2364s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s 2364s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2364s 2364s The above exception was the direct cause of the following exception: 2364s 2364s @pytest.fixture 2364s def postgresql_psycopg2_engine(): 2364s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2364s td.versioned_importorskip("psycopg2") 2364s engine = sqlalchemy.create_engine( 2364s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2364s poolclass=sqlalchemy.pool.NullPool, 2364s ) 2364s yield engine 2364s > for view in get_all_views(engine): 2364s 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2364s return inspect(conn).get_view_names() 2364s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2364s ret = reg(subject) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2364s return Inspector._construct(Inspector._init_engine, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2364s init(self, bind) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2364s engine.connect().close() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2364s return self._connection_cls(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2364s Connection._handle_dbapi_exception_noconnection( 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2364s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2364s self._dbapi_connection = engine.raw_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2364s connection_factory = None, cursor_factory = None 2364s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2364s kwasync = {} 2364s 2364s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2364s """ 2364s Create a new database connection. 2364s 2364s The connection parameters can be specified as a string: 2364s 2364s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2364s 2364s or using a set of keyword arguments: 2364s 2364s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2364s 2364s Or as a mix of both. The basic connection parameters are: 2364s 2364s - *dbname*: the database name 2364s - *database*: the database name (only as keyword argument) 2364s - *user*: user name used to authenticate 2364s - *password*: password used to authenticate 2364s - *host*: database host address (defaults to UNIX socket if not provided) 2364s - *port*: connection port number (defaults to 5432 if not provided) 2364s 2364s Using the *connection_factory* parameter a different class or connections 2364s factory can be specified. It should be a callable object taking a dsn 2364s argument. 2364s 2364s Using the *cursor_factory* parameter, a new default cursor factory will be 2364s used by cursor(). 2364s 2364s Using *async*=True an asynchronous connection will be created. *async_* is 2364s a valid alias (for Python versions where ``async`` is a keyword). 2364s 2364s Any other keyword parameter will be passed to the underlying client 2364s library: the list of supported parameters depends on the library version. 2364s 2364s """ 2364s kwasync = {} 2364s if 'async' in kwargs: 2364s kwasync['async'] = kwargs.pop('async') 2364s if 'async_' in kwargs: 2364s kwasync['async_'] = kwargs.pop('async_') 2364s 2364s dsn = _ext.make_dsn(dsn, **kwargs) 2364s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2364s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2364s E Is the server running on that host and accepting TCP/IP connections? 2364s E 2364s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2364s 2364s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2364s ____ ERROR at teardown of test_to_sql_exist[replace-1-mysql_pymysql_engine] ____ 2364s self = , sock = None 2364s 2364s def connect(self, sock=None): 2364s self._closed = False 2364s try: 2364s if sock is None: 2364s if self.unix_socket: 2364s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2364s sock.settimeout(self.connect_timeout) 2364s sock.connect(self.unix_socket) 2364s self.host_info = "Localhost via UNIX socket" 2364s self._secure = True 2364s if DEBUG: 2364s print("connected using unix_socket") 2364s else: 2364s kwargs = {} 2364s if self.bind_address is not None: 2364s kwargs["source_address"] = (self.bind_address, 0) 2364s while True: 2364s try: 2364s > sock = socket.create_connection( 2364s (self.host, self.port), self.connect_timeout, **kwargs 2364s ) 2364s 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3.13/socket.py:864: in create_connection 2364s raise exceptions[0] 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s address = ('localhost', 3306), timeout = 10, source_address = None 2364s 2364s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2364s source_address=None, *, all_errors=False): 2364s """Connect to *address* and return the socket object. 2364s 2364s Convenience function. Connect to *address* (a 2-tuple ``(host, 2364s port)``) and return the socket object. Passing the optional 2364s *timeout* parameter will set the timeout on the socket instance 2364s before attempting to connect. If no *timeout* is supplied, the 2364s global default timeout setting returned by :func:`getdefaulttimeout` 2364s is used. If *source_address* is set it must be a tuple of (host, port) 2364s for the socket to bind as a source address before making the connection. 2364s A host of '' or port 0 tells the OS to use the default. When a connection 2364s cannot be created, raises the last error if *all_errors* is False, 2364s and an ExceptionGroup of all errors if *all_errors* is True. 2364s """ 2364s 2364s host, port = address 2364s exceptions = [] 2364s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2364s af, socktype, proto, canonname, sa = res 2364s sock = None 2364s try: 2364s sock = socket(af, socktype, proto) 2364s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2364s sock.settimeout(timeout) 2364s if source_address: 2364s sock.bind(source_address) 2364s > sock.connect(sa) 2364s E ConnectionRefusedError: [Errno 111] Connection refused 2364s 2364s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2364s 2364s During handling of the above exception, another exception occurred: 2364s 2364s self = 2364s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2364s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2364s 2364s def __init__( 2364s self, 2364s engine: Engine, 2364s connection: Optional[PoolProxiedConnection] = None, 2364s _has_events: Optional[bool] = None, 2364s _allow_revalidate: bool = True, 2364s _allow_autobegin: bool = True, 2364s ): 2364s """Construct a new Connection.""" 2364s self.engine = engine 2364s self.dialect = dialect = engine.dialect 2364s 2364s if connection is None: 2364s try: 2364s > self._dbapi_connection = engine.raw_connection() 2364s 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2364s return self.pool.connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2364s return _ConnectionFairy._checkout(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2364s fairy = _ConnectionRecord.checkout(pool) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2364s rec = pool._do_get() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2364s return self._create_connection() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2364s return _ConnectionRecord(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2364s self.__connect() 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2364s with util.safe_reraise(): 2364s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2364s raise exc_value.with_traceback(exc_tb) 2364s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2364s self.dbapi_connection = connection = pool._invoke_creator(self) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2364s return dialect.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2364s return self.loaded_dbapi.connect(*cargs, **cparams) 2364s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2364s self.connect() 2364s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2364s 2364s self = , sock = None 2364s 2364s def connect(self, sock=None): 2364s self._closed = False 2364s try: 2364s if sock is None: 2364s if self.unix_socket: 2364s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2364s sock.settimeout(self.connect_timeout) 2364s sock.connect(self.unix_socket) 2364s self.host_info = "Localhost via UNIX socket" 2364s self._secure = True 2364s if DEBUG: 2364s print("connected using unix_socket") 2364s else: 2364s kwargs = {} 2364s if self.bind_address is not None: 2364s kwargs["source_address"] = (self.bind_address, 0) 2364s while True: 2364s try: 2364s sock = socket.create_connection( 2364s (self.host, self.port), self.connect_timeout, **kwargs 2364s ) 2364s break 2364s except OSError as e: 2364s if e.errno == errno.EINTR: 2364s continue 2364s raise 2364s self.host_info = "socket %s:%d" % (self.host, self.port) 2364s if DEBUG: 2364s print("connected using socket") 2364s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2364s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2364s sock.settimeout(None) 2364s 2364s self._sock = sock 2364s self._rfile = sock.makefile("rb") 2364s self._next_seq_id = 0 2364s 2364s self._get_server_information() 2364s self._request_authentication() 2364s 2364s # Send "SET NAMES" query on init for: 2364s # - Ensure charaset (and collation) is set to the server. 2364s # - collation_id in handshake packet may be ignored. 2364s # - If collation is not specified, we don't know what is server's 2364s # default collation for the charset. For example, default collation 2364s # of utf8mb4 is: 2364s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2364s # - MySQL 8.0: utf8mb4_0900_ai_ci 2364s # 2364s # Reference: 2364s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2364s # - https://github.com/wagtail/wagtail/issues/9477 2364s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2364s self.set_character_set(self.charset, self.collation) 2364s 2364s if self.sql_mode is not None: 2364s c = self.cursor() 2364s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2364s c.close() 2364s 2364s if self.init_command is not None: 2364s c = self.cursor() 2364s c.execute(self.init_command) 2364s c.close() 2364s 2364s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _____ ERROR at teardown of test_to_sql_exist[replace-1-mysql_pymysql_conn] _____ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _ ERROR at teardown of test_to_sql_exist[replace-1-postgresql_psycopg2_engine] _ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s __ ERROR at teardown of test_to_sql_exist[replace-1-postgresql_psycopg2_conn] __ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s ____ ERROR at teardown of test_to_sql_exist[append-2-mysql_pymysql_engine] _____ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _____ ERROR at teardown of test_to_sql_exist[append-2-mysql_pymysql_conn] ______ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _ ERROR at teardown of test_to_sql_exist[append-2-postgresql_psycopg2_engine] __ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s __ ERROR at teardown of test_to_sql_exist[append-2-postgresql_psycopg2_conn] ___ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s ______ ERROR at teardown of test_to_sql_exist_fail[mysql_pymysql_engine] _______ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _______ ERROR at teardown of test_to_sql_exist_fail[mysql_pymysql_conn] ________ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s ___ ERROR at teardown of test_to_sql_exist_fail[postgresql_psycopg2_engine] ____ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s ____ ERROR at teardown of test_to_sql_exist_fail[postgresql_psycopg2_conn] _____ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _____ ERROR at teardown of test_read_iris_query[mysql_pymysql_engine_iris] _____ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s ______ ERROR at teardown of test_read_iris_query[mysql_pymysql_conn_iris] ______ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s __ ERROR at teardown of test_read_iris_query[postgresql_psycopg2_engine_iris] __ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s ___ ERROR at teardown of test_read_iris_query[postgresql_psycopg2_conn_iris] ___ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _ ERROR at teardown of test_read_iris_query_chunksize[mysql_pymysql_engine_iris] _ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _ ERROR at teardown of test_read_iris_query_chunksize[mysql_pymysql_conn_iris] _ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _ ERROR at teardown of test_read_iris_query_chunksize[postgresql_psycopg2_engine_iris] _ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _ ERROR at teardown of test_read_iris_query_chunksize[postgresql_psycopg2_conn_iris] _ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _ ERROR at teardown of test_read_iris_query_expression_with_parameter[mysql_pymysql_engine_iris] _ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _ ERROR at teardown of test_read_iris_query_expression_with_parameter[mysql_pymysql_conn_iris] _ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _ ERROR at teardown of test_read_iris_query_expression_with_parameter[postgresql_psycopg2_engine_iris] _ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _ ERROR at teardown of test_read_iris_query_expression_with_parameter[postgresql_psycopg2_conn_iris] _ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _ ERROR at teardown of test_read_iris_query_string_with_parameter[mysql_pymysql_engine_iris] _ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _ ERROR at teardown of test_read_iris_query_string_with_parameter[mysql_pymysql_conn_iris] _ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _ ERROR at teardown of test_read_iris_query_string_with_parameter[postgresql_psycopg2_engine_iris] _ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _ ERROR at teardown of test_read_iris_query_string_with_parameter[postgresql_psycopg2_conn_iris] _ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _____ ERROR at teardown of test_read_iris_table[mysql_pymysql_engine_iris] _____ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s ______ ERROR at teardown of test_read_iris_table[mysql_pymysql_conn_iris] ______ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s __ ERROR at teardown of test_read_iris_table[postgresql_psycopg2_engine_iris] __ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s ___ ERROR at teardown of test_read_iris_table[postgresql_psycopg2_conn_iris] ___ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _ ERROR at teardown of test_read_iris_table_chunksize[mysql_pymysql_engine_iris] _ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _ ERROR at teardown of test_read_iris_table_chunksize[mysql_pymysql_conn_iris] _ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _ ERROR at teardown of test_read_iris_table_chunksize[postgresql_psycopg2_engine_iris] _ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _ ERROR at teardown of test_read_iris_table_chunksize[postgresql_psycopg2_conn_iris] _ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _______ ERROR at teardown of test_to_sql_callable[mysql_pymysql_engine] ________ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s ________ ERROR at teardown of test_to_sql_callable[mysql_pymysql_conn] _________ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s ____ ERROR at teardown of test_to_sql_callable[postgresql_psycopg2_engine] _____ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _____ ERROR at teardown of test_to_sql_callable[postgresql_psycopg2_conn] ______ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _ ERROR at teardown of test_default_type_conversion[mysql_pymysql_engine_types] _ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _ ERROR at teardown of test_default_type_conversion[mysql_pymysql_conn_types] __ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _ ERROR at teardown of test_default_type_conversion[postgresql_psycopg2_engine_types] _ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _ ERROR at teardown of test_default_type_conversion[postgresql_psycopg2_conn_types] _ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s ________ ERROR at teardown of test_read_procedure[mysql_pymysql_engine] ________ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _________ ERROR at teardown of test_read_procedure[mysql_pymysql_conn] _________ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _ ERROR at teardown of test_copy_from_callable_insertion_method[2-postgresql_psycopg2_engine] _ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _ ERROR at teardown of test_copy_from_callable_insertion_method[2-postgresql_psycopg2_conn] _ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _ ERROR at teardown of test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_engine] _ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _ ERROR at teardown of test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_conn] _ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _ ERROR at teardown of test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_engine] _ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _ ERROR at teardown of test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_conn] _ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _ ERROR at teardown of test_to_sql_on_public_schema[postgresql_psycopg2_engine] _ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _ ERROR at teardown of test_to_sql_on_public_schema[postgresql_psycopg2_conn] __ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _ ERROR at teardown of test_insertion_method_on_conflict_update[mysql_pymysql_engine] _ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _ ERROR at teardown of test_insertion_method_on_conflict_update[mysql_pymysql_conn] _ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s ___ ERROR at teardown of test_read_view_postgres[postgresql_psycopg2_engine] ___ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s ____ ERROR at teardown of test_read_view_postgres[postgresql_psycopg2_conn] ____ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _ ERROR at teardown of test_read_sql_iris_parameter[mysql_pymysql_engine_iris] _ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s __ ERROR at teardown of test_read_sql_iris_parameter[mysql_pymysql_conn_iris] __ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _ ERROR at teardown of test_read_sql_iris_parameter[postgresql_psycopg2_engine_iris] _ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _ ERROR at teardown of test_read_sql_iris_parameter[postgresql_psycopg2_conn_iris] _ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _ ERROR at teardown of test_read_sql_iris_named_parameter[mysql_pymysql_engine_iris] _ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _ ERROR at teardown of test_read_sql_iris_named_parameter[mysql_pymysql_conn_iris] _ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _ ERROR at teardown of test_read_sql_iris_named_parameter[postgresql_psycopg2_engine_iris] _ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _ ERROR at teardown of test_read_sql_iris_named_parameter[postgresql_psycopg2_conn_iris] _ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s ____ ERROR at teardown of test_api_read_sql_view[mysql_pymysql_engine_iris] ____ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _____ ERROR at teardown of test_api_read_sql_view[mysql_pymysql_conn_iris] _____ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _ ERROR at teardown of test_api_read_sql_view[postgresql_psycopg2_engine_iris] _ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s __ ERROR at teardown of test_api_read_sql_view[postgresql_psycopg2_conn_iris] __ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _ ERROR at teardown of test_api_read_sql_with_chunksize_no_result[mysql_pymysql_engine_iris] _ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _ ERROR at teardown of test_api_read_sql_with_chunksize_no_result[mysql_pymysql_conn_iris] _ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _ ERROR at teardown of test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_engine_iris] _ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _ ERROR at teardown of test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_conn_iris] _ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s __________ ERROR at teardown of test_api_to_sql[mysql_pymysql_engine] __________ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s ___________ ERROR at teardown of test_api_to_sql[mysql_pymysql_conn] ___________ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _______ ERROR at teardown of test_api_to_sql[postgresql_psycopg2_engine] _______ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s ________ ERROR at teardown of test_api_to_sql[postgresql_psycopg2_conn] ________ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _______ ERROR at teardown of test_api_to_sql_fail[mysql_pymysql_engine] ________ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s ________ ERROR at teardown of test_api_to_sql_fail[mysql_pymysql_conn] _________ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s ____ ERROR at teardown of test_api_to_sql_fail[postgresql_psycopg2_engine] _____ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _____ ERROR at teardown of test_api_to_sql_fail[postgresql_psycopg2_conn] ______ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s ______ ERROR at teardown of test_api_to_sql_replace[mysql_pymysql_engine] ______ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _______ ERROR at teardown of test_api_to_sql_replace[mysql_pymysql_conn] _______ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s ___ ERROR at teardown of test_api_to_sql_replace[postgresql_psycopg2_engine] ___ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s ____ ERROR at teardown of test_api_to_sql_replace[postgresql_psycopg2_conn] ____ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s ______ ERROR at teardown of test_api_to_sql_append[mysql_pymysql_engine] _______ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _______ ERROR at teardown of test_api_to_sql_append[mysql_pymysql_conn] ________ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s ___ ERROR at teardown of test_api_to_sql_append[postgresql_psycopg2_engine] ____ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s ____ ERROR at teardown of test_api_to_sql_append[postgresql_psycopg2_conn] _____ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s ___ ERROR at teardown of test_api_to_sql_type_mapping[mysql_pymysql_engine] ____ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s ____ ERROR at teardown of test_api_to_sql_type_mapping[mysql_pymysql_conn] _____ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _ ERROR at teardown of test_api_to_sql_type_mapping[postgresql_psycopg2_engine] _ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s _ ERROR at teardown of test_api_to_sql_type_mapping[postgresql_psycopg2_conn] __ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s ______ ERROR at teardown of test_api_to_sql_series[mysql_pymysql_engine] _______ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _______ ERROR at teardown of test_api_to_sql_series[mysql_pymysql_conn] ________ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s ___ ERROR at teardown of test_api_to_sql_series[postgresql_psycopg2_engine] ____ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s ____ ERROR at teardown of test_api_to_sql_series[postgresql_psycopg2_conn] _____ 2365s self = 2365s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2365s connection = None, _has_events = None, _allow_revalidate = True 2365s _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def postgresql_psycopg2_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s td.versioned_importorskip("psycopg2") 2365s engine = sqlalchemy.create_engine( 2365s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2365s connection_factory = None, cursor_factory = None 2365s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2365s kwasync = {} 2365s 2365s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2365s """ 2365s Create a new database connection. 2365s 2365s The connection parameters can be specified as a string: 2365s 2365s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2365s 2365s or using a set of keyword arguments: 2365s 2365s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2365s 2365s Or as a mix of both. The basic connection parameters are: 2365s 2365s - *dbname*: the database name 2365s - *database*: the database name (only as keyword argument) 2365s - *user*: user name used to authenticate 2365s - *password*: password used to authenticate 2365s - *host*: database host address (defaults to UNIX socket if not provided) 2365s - *port*: connection port number (defaults to 5432 if not provided) 2365s 2365s Using the *connection_factory* parameter a different class or connections 2365s factory can be specified. It should be a callable object taking a dsn 2365s argument. 2365s 2365s Using the *cursor_factory* parameter, a new default cursor factory will be 2365s used by cursor(). 2365s 2365s Using *async*=True an asynchronous connection will be created. *async_* is 2365s a valid alias (for Python versions where ``async`` is a keyword). 2365s 2365s Any other keyword parameter will be passed to the underlying client 2365s library: the list of supported parameters depends on the library version. 2365s 2365s """ 2365s kwasync = {} 2365s if 'async' in kwargs: 2365s kwasync['async'] = kwargs.pop('async') 2365s if 'async_' in kwargs: 2365s kwasync['async_'] = kwargs.pop('async_') 2365s 2365s dsn = _ext.make_dsn(dsn, **kwargs) 2365s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2365s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2365s E Is the server running on that host and accepting TCP/IP connections? 2365s E 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2365s ________ ERROR at teardown of test_api_roundtrip[mysql_pymysql_engine] _________ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _________ ERROR at teardown of test_api_roundtrip[mysql_pymysql_conn] __________ 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s > sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3.13/socket.py:864: in create_connection 2365s raise exceptions[0] 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s address = ('localhost', 3306), timeout = 10, source_address = None 2365s 2365s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2365s source_address=None, *, all_errors=False): 2365s """Connect to *address* and return the socket object. 2365s 2365s Convenience function. Connect to *address* (a 2-tuple ``(host, 2365s port)``) and return the socket object. Passing the optional 2365s *timeout* parameter will set the timeout on the socket instance 2365s before attempting to connect. If no *timeout* is supplied, the 2365s global default timeout setting returned by :func:`getdefaulttimeout` 2365s is used. If *source_address* is set it must be a tuple of (host, port) 2365s for the socket to bind as a source address before making the connection. 2365s A host of '' or port 0 tells the OS to use the default. When a connection 2365s cannot be created, raises the last error if *all_errors* is False, 2365s and an ExceptionGroup of all errors if *all_errors* is True. 2365s """ 2365s 2365s host, port = address 2365s exceptions = [] 2365s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2365s af, socktype, proto, canonname, sa = res 2365s sock = None 2365s try: 2365s sock = socket(af, socktype, proto) 2365s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2365s sock.settimeout(timeout) 2365s if source_address: 2365s sock.bind(source_address) 2365s > sock.connect(sa) 2365s E ConnectionRefusedError: [Errno 111] Connection refused 2365s 2365s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2365s 2365s During handling of the above exception, another exception occurred: 2365s 2365s self = 2365s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2365s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2365s 2365s def __init__( 2365s self, 2365s engine: Engine, 2365s connection: Optional[PoolProxiedConnection] = None, 2365s _has_events: Optional[bool] = None, 2365s _allow_revalidate: bool = True, 2365s _allow_autobegin: bool = True, 2365s ): 2365s """Construct a new Connection.""" 2365s self.engine = engine 2365s self.dialect = dialect = engine.dialect 2365s 2365s if connection is None: 2365s try: 2365s > self._dbapi_connection = engine.raw_connection() 2365s 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s 2365s The above exception was the direct cause of the following exception: 2365s 2365s @pytest.fixture 2365s def mysql_pymysql_engine(): 2365s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2365s pymysql = td.versioned_importorskip("pymysql") 2365s engine = sqlalchemy.create_engine( 2365s "mysql+pymysql://root@localhost:3306/pandas", 2365s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2365s poolclass=sqlalchemy.pool.NullPool, 2365s ) 2365s yield engine 2365s > for view in get_all_views(engine): 2365s 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2365s return inspect(conn).get_view_names() 2365s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2365s ret = reg(subject) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2365s return Inspector._construct(Inspector._init_engine, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2365s init(self, bind) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2365s engine.connect().close() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2365s return self._connection_cls(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2365s Connection._handle_dbapi_exception_noconnection( 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2365s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2365s self._dbapi_connection = engine.raw_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2365s return self.pool.connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2365s return _ConnectionFairy._checkout(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2365s fairy = _ConnectionRecord.checkout(pool) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2365s rec = pool._do_get() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2365s return self._create_connection() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2365s return _ConnectionRecord(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2365s self.__connect() 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2365s with util.safe_reraise(): 2365s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2365s raise exc_value.with_traceback(exc_tb) 2365s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2365s self.dbapi_connection = connection = pool._invoke_creator(self) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2365s return dialect.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2365s return self.loaded_dbapi.connect(*cargs, **cparams) 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2365s self.connect() 2365s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2365s 2365s self = , sock = None 2365s 2365s def connect(self, sock=None): 2365s self._closed = False 2365s try: 2365s if sock is None: 2365s if self.unix_socket: 2365s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2365s sock.settimeout(self.connect_timeout) 2365s sock.connect(self.unix_socket) 2365s self.host_info = "Localhost via UNIX socket" 2365s self._secure = True 2365s if DEBUG: 2365s print("connected using unix_socket") 2365s else: 2365s kwargs = {} 2365s if self.bind_address is not None: 2365s kwargs["source_address"] = (self.bind_address, 0) 2365s while True: 2365s try: 2365s sock = socket.create_connection( 2365s (self.host, self.port), self.connect_timeout, **kwargs 2365s ) 2365s break 2365s except OSError as e: 2365s if e.errno == errno.EINTR: 2365s continue 2365s raise 2365s self.host_info = "socket %s:%d" % (self.host, self.port) 2365s if DEBUG: 2365s print("connected using socket") 2365s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2365s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2365s sock.settimeout(None) 2365s 2365s self._sock = sock 2365s self._rfile = sock.makefile("rb") 2365s self._next_seq_id = 0 2365s 2365s self._get_server_information() 2365s self._request_authentication() 2365s 2365s # Send "SET NAMES" query on init for: 2365s # - Ensure charaset (and collation) is set to the server. 2365s # - collation_id in handshake packet may be ignored. 2365s # - If collation is not specified, we don't know what is server's 2365s # default collation for the charset. For example, default collation 2365s # of utf8mb4 is: 2365s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2365s # - MySQL 8.0: utf8mb4_0900_ai_ci 2365s # 2365s # Reference: 2365s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2365s # - https://github.com/wagtail/wagtail/issues/9477 2365s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2365s self.set_character_set(self.charset, self.collation) 2365s 2365s if self.sql_mode is not None: 2365s c = self.cursor() 2365s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2365s c.close() 2365s 2365s if self.init_command is not None: 2365s c = self.cursor() 2365s c.execute(self.init_command) 2365s c.close() 2365s 2365s if self.autocommit_mode is not None: 2365s self.autocommit(self.autocommit_mode) 2365s except BaseException as e: 2365s self._rfile = None 2365s if sock is not None: 2365s try: 2365s sock.close() 2365s except: # noqa 2365s pass 2365s 2365s if isinstance(e, (OSError, IOError)): 2365s exc = err.OperationalError( 2365s CR.CR_CONN_HOST_ERROR, 2365s f"Can't connect to MySQL server on {self.host!r} ({e})", 2365s ) 2365s # Keep original exception and traceback to investigate error. 2365s exc.original_exception = e 2365s exc.traceback = traceback.format_exc() 2365s if DEBUG: 2365s print(exc.traceback) 2365s > raise exc 2365s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2365s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2365s 2365s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2365s _____ ERROR at teardown of test_api_roundtrip[postgresql_psycopg2_engine] ______ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s ______ ERROR at teardown of test_api_roundtrip[postgresql_psycopg2_conn] _______ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s ___ ERROR at teardown of test_api_roundtrip_chunksize[mysql_pymysql_engine] ____ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s ____ ERROR at teardown of test_api_roundtrip_chunksize[mysql_pymysql_conn] _____ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_roundtrip_chunksize[postgresql_psycopg2_engine] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_roundtrip_chunksize[postgresql_psycopg2_conn] __ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _____ ERROR at teardown of test_api_execute_sql[mysql_pymysql_engine_iris] _____ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s ______ ERROR at teardown of test_api_execute_sql[mysql_pymysql_conn_iris] ______ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s __ ERROR at teardown of test_api_execute_sql[postgresql_psycopg2_engine_iris] __ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s ___ ERROR at teardown of test_api_execute_sql[postgresql_psycopg2_conn_iris] ___ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s ____ ERROR at teardown of test_api_date_parsing[mysql_pymysql_engine_types] ____ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _____ ERROR at teardown of test_api_date_parsing[mysql_pymysql_conn_types] _____ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_date_parsing[postgresql_psycopg2_engine_types] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s __ ERROR at teardown of test_api_date_parsing[postgresql_psycopg2_conn_types] __ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_engine_types] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_conn_types] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_engine_types] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_conn_types] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_engine_types] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_conn_types] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_engine_types] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_conn_types] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_engine_types] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_conn_types] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_engine_types] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_conn_types] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_engine_types] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_conn_types] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_engine_types] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_conn_types] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_engine_types] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_conn_types] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_engine_types] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_conn_types] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_engine_types] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_conn_types] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_engine_types] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_conn_types] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_engine_types] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_conn_types] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_engine_types] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_conn_types] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_engine_types] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_conn_types] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_engine_types] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_conn_types] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_engine_types] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_conn_types] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_engine_types] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_conn_types] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s ___ ERROR at teardown of test_api_date_and_index[mysql_pymysql_engine_types] ___ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s ____ ERROR at teardown of test_api_date_and_index[mysql_pymysql_conn_types] ____ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_date_and_index[postgresql_psycopg2_engine_types] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_date_and_index[postgresql_psycopg2_conn_types] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s ________ ERROR at teardown of test_api_timedelta[mysql_pymysql_engine] _________ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _________ ERROR at teardown of test_api_timedelta[mysql_pymysql_conn] __________ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _____ ERROR at teardown of test_api_timedelta[postgresql_psycopg2_engine] ______ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s ______ ERROR at teardown of test_api_timedelta[postgresql_psycopg2_conn] _______ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s ______ ERROR at teardown of test_api_complex_raises[mysql_pymysql_engine] ______ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _______ ERROR at teardown of test_api_complex_raises[mysql_pymysql_conn] _______ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s ___ ERROR at teardown of test_api_complex_raises[postgresql_psycopg2_engine] ___ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s ____ ERROR at teardown of test_api_complex_raises[postgresql_psycopg2_conn] ____ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_to_sql_index_label[None-None-index-mysql_pymysql_engine] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_to_sql_index_label[None-None-index-mysql_pymysql_conn] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_engine] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_conn] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_engine] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_conn] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_engine] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_conn] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_engine] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_conn] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_engine] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_conn] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_engine] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_conn] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_engine] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_conn] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_to_sql_index_label[0-None-0-mysql_pymysql_engine] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_to_sql_index_label[0-None-0-mysql_pymysql_conn] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_engine] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_conn] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_to_sql_index_label[None-0-0-mysql_pymysql_engine] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_to_sql_index_label[None-0-0-mysql_pymysql_conn] _ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_engine] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_conn] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_to_sql_index_label_multiindex[postgresql_psycopg2_engine] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_to_sql_index_label_multiindex[postgresql_psycopg2_conn] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s ___ ERROR at teardown of test_api_multiindex_roundtrip[mysql_pymysql_engine] ___ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s ____ ERROR at teardown of test_api_multiindex_roundtrip[mysql_pymysql_conn] ____ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_multiindex_roundtrip[postgresql_psycopg2_engine] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_multiindex_roundtrip[postgresql_psycopg2_conn] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s ___ ERROR at teardown of test_api_dtype_argument[None-mysql_pymysql_engine] ____ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s ____ ERROR at teardown of test_api_dtype_argument[None-mysql_pymysql_conn] _____ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_dtype_argument[None-postgresql_psycopg2_engine] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_dtype_argument[None-postgresql_psycopg2_conn] __ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s ____ ERROR at teardown of test_api_dtype_argument[int-mysql_pymysql_engine] ____ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _____ ERROR at teardown of test_api_dtype_argument[int-mysql_pymysql_conn] _____ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_dtype_argument[int-postgresql_psycopg2_engine] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s __ ERROR at teardown of test_api_dtype_argument[int-postgresql_psycopg2_conn] __ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s ___ ERROR at teardown of test_api_dtype_argument[float-mysql_pymysql_engine] ___ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s ____ ERROR at teardown of test_api_dtype_argument[float-mysql_pymysql_conn] ____ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_dtype_argument[float-postgresql_psycopg2_engine] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_dtype_argument[float-postgresql_psycopg2_conn] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s __ ERROR at teardown of test_api_dtype_argument[dtype3-mysql_pymysql_engine] ___ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s ___ ERROR at teardown of test_api_dtype_argument[dtype3-mysql_pymysql_conn] ____ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_dtype_argument[dtype3-postgresql_psycopg2_engine] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_dtype_argument[dtype3-postgresql_psycopg2_conn] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s ____ ERROR at teardown of test_api_integer_col_names[mysql_pymysql_engine] _____ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _____ ERROR at teardown of test_api_integer_col_names[mysql_pymysql_conn] ______ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_integer_col_names[postgresql_psycopg2_engine] __ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s __ ERROR at teardown of test_api_integer_col_names[postgresql_psycopg2_conn] ___ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s ________ ERROR at teardown of test_api_get_schema[mysql_pymysql_engine] ________ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _________ ERROR at teardown of test_api_get_schema[mysql_pymysql_conn] _________ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _____ ERROR at teardown of test_api_get_schema[postgresql_psycopg2_engine] _____ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s ______ ERROR at teardown of test_api_get_schema[postgresql_psycopg2_conn] ______ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s __ ERROR at teardown of test_api_get_schema_with_schema[mysql_pymysql_engine] __ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s ___ ERROR at teardown of test_api_get_schema_with_schema[mysql_pymysql_conn] ___ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_get_schema_with_schema[postgresql_psycopg2_engine] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_get_schema_with_schema[postgresql_psycopg2_conn] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s ____ ERROR at teardown of test_api_get_schema_dtypes[mysql_pymysql_engine] _____ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _____ ERROR at teardown of test_api_get_schema_dtypes[mysql_pymysql_conn] ______ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_get_schema_dtypes[postgresql_psycopg2_engine] __ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s __ ERROR at teardown of test_api_get_schema_dtypes[postgresql_psycopg2_conn] ___ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _____ ERROR at teardown of test_api_get_schema_keys[mysql_pymysql_engine] ______ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s ______ ERROR at teardown of test_api_get_schema_keys[mysql_pymysql_conn] _______ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s __ ERROR at teardown of test_api_get_schema_keys[postgresql_psycopg2_engine] ___ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s ___ ERROR at teardown of test_api_get_schema_keys[postgresql_psycopg2_conn] ____ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s ______ ERROR at teardown of test_api_chunksize_read[mysql_pymysql_engine] ______ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _______ ERROR at teardown of test_api_chunksize_read[mysql_pymysql_conn] _______ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s ___ ERROR at teardown of test_api_chunksize_read[postgresql_psycopg2_engine] ___ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s ____ ERROR at teardown of test_api_chunksize_read[postgresql_psycopg2_conn] ____ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _______ ERROR at teardown of test_api_categorical[mysql_pymysql_engine] ________ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s ________ ERROR at teardown of test_api_categorical[mysql_pymysql_conn] _________ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s ____ ERROR at teardown of test_api_categorical[postgresql_psycopg2_engine] _____ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _____ ERROR at teardown of test_api_categorical[postgresql_psycopg2_conn] ______ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s ___ ERROR at teardown of test_api_unicode_column_name[mysql_pymysql_engine] ____ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s ____ ERROR at teardown of test_api_unicode_column_name[mysql_pymysql_conn] _____ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_unicode_column_name[postgresql_psycopg2_engine] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s _ ERROR at teardown of test_api_unicode_column_name[postgresql_psycopg2_conn] __ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s ____ ERROR at teardown of test_api_escaped_table_name[mysql_pymysql_engine] ____ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _____ ERROR at teardown of test_api_escaped_table_name[mysql_pymysql_conn] _____ 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s > sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3.13/socket.py:864: in create_connection 2366s raise exceptions[0] 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s address = ('localhost', 3306), timeout = 10, source_address = None 2366s 2366s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2366s source_address=None, *, all_errors=False): 2366s """Connect to *address* and return the socket object. 2366s 2366s Convenience function. Connect to *address* (a 2-tuple ``(host, 2366s port)``) and return the socket object. Passing the optional 2366s *timeout* parameter will set the timeout on the socket instance 2366s before attempting to connect. If no *timeout* is supplied, the 2366s global default timeout setting returned by :func:`getdefaulttimeout` 2366s is used. If *source_address* is set it must be a tuple of (host, port) 2366s for the socket to bind as a source address before making the connection. 2366s A host of '' or port 0 tells the OS to use the default. When a connection 2366s cannot be created, raises the last error if *all_errors* is False, 2366s and an ExceptionGroup of all errors if *all_errors* is True. 2366s """ 2366s 2366s host, port = address 2366s exceptions = [] 2366s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2366s af, socktype, proto, canonname, sa = res 2366s sock = None 2366s try: 2366s sock = socket(af, socktype, proto) 2366s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2366s sock.settimeout(timeout) 2366s if source_address: 2366s sock.bind(source_address) 2366s > sock.connect(sa) 2366s E ConnectionRefusedError: [Errno 111] Connection refused 2366s 2366s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2366s 2366s During handling of the above exception, another exception occurred: 2366s 2366s self = 2366s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2366s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def mysql_pymysql_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s pymysql = td.versioned_importorskip("pymysql") 2366s engine = sqlalchemy.create_engine( 2366s "mysql+pymysql://root@localhost:3306/pandas", 2366s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2366s self.connect() 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s self = , sock = None 2366s 2366s def connect(self, sock=None): 2366s self._closed = False 2366s try: 2366s if sock is None: 2366s if self.unix_socket: 2366s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2366s sock.settimeout(self.connect_timeout) 2366s sock.connect(self.unix_socket) 2366s self.host_info = "Localhost via UNIX socket" 2366s self._secure = True 2366s if DEBUG: 2366s print("connected using unix_socket") 2366s else: 2366s kwargs = {} 2366s if self.bind_address is not None: 2366s kwargs["source_address"] = (self.bind_address, 0) 2366s while True: 2366s try: 2366s sock = socket.create_connection( 2366s (self.host, self.port), self.connect_timeout, **kwargs 2366s ) 2366s break 2366s except OSError as e: 2366s if e.errno == errno.EINTR: 2366s continue 2366s raise 2366s self.host_info = "socket %s:%d" % (self.host, self.port) 2366s if DEBUG: 2366s print("connected using socket") 2366s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2366s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2366s sock.settimeout(None) 2366s 2366s self._sock = sock 2366s self._rfile = sock.makefile("rb") 2366s self._next_seq_id = 0 2366s 2366s self._get_server_information() 2366s self._request_authentication() 2366s 2366s # Send "SET NAMES" query on init for: 2366s # - Ensure charaset (and collation) is set to the server. 2366s # - collation_id in handshake packet may be ignored. 2366s # - If collation is not specified, we don't know what is server's 2366s # default collation for the charset. For example, default collation 2366s # of utf8mb4 is: 2366s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2366s # - MySQL 8.0: utf8mb4_0900_ai_ci 2366s # 2366s # Reference: 2366s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2366s # - https://github.com/wagtail/wagtail/issues/9477 2366s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2366s self.set_character_set(self.charset, self.collation) 2366s 2366s if self.sql_mode is not None: 2366s c = self.cursor() 2366s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2366s c.close() 2366s 2366s if self.init_command is not None: 2366s c = self.cursor() 2366s c.execute(self.init_command) 2366s c.close() 2366s 2366s if self.autocommit_mode is not None: 2366s self.autocommit(self.autocommit_mode) 2366s except BaseException as e: 2366s self._rfile = None 2366s if sock is not None: 2366s try: 2366s sock.close() 2366s except: # noqa 2366s pass 2366s 2366s if isinstance(e, (OSError, IOError)): 2366s exc = err.OperationalError( 2366s CR.CR_CONN_HOST_ERROR, 2366s f"Can't connect to MySQL server on {self.host!r} ({e})", 2366s ) 2366s # Keep original exception and traceback to investigate error. 2366s exc.original_exception = e 2366s exc.traceback = traceback.format_exc() 2366s if DEBUG: 2366s print(exc.traceback) 2366s > raise exc 2366s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2366s _ ERROR at teardown of test_api_escaped_table_name[postgresql_psycopg2_engine] _ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2366s engine.connect().close() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2366s return self._connection_cls(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2366s Connection._handle_dbapi_exception_noconnection( 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2366s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2366s self._dbapi_connection = engine.raw_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E 2366s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s __ ERROR at teardown of test_api_escaped_table_name[postgresql_psycopg2_conn] __ 2366s self = 2366s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2366s connection = None, _has_events = None, _allow_revalidate = True 2366s _allow_autobegin = True 2366s 2366s def __init__( 2366s self, 2366s engine: Engine, 2366s connection: Optional[PoolProxiedConnection] = None, 2366s _has_events: Optional[bool] = None, 2366s _allow_revalidate: bool = True, 2366s _allow_autobegin: bool = True, 2366s ): 2366s """Construct a new Connection.""" 2366s self.engine = engine 2366s self.dialect = dialect = engine.dialect 2366s 2366s if connection is None: 2366s try: 2366s > self._dbapi_connection = engine.raw_connection() 2366s 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2366s return self.pool.connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2366s return _ConnectionFairy._checkout(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2366s fairy = _ConnectionRecord.checkout(pool) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2366s rec = pool._do_get() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2366s return self._create_connection() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2366s return _ConnectionRecord(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2366s self.__connect() 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2366s with util.safe_reraise(): 2366s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2366s raise exc_value.with_traceback(exc_tb) 2366s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2366s self.dbapi_connection = connection = pool._invoke_creator(self) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2366s return dialect.connect(*cargs, **cparams) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2366s return self.loaded_dbapi.connect(*cargs, **cparams) 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s 2366s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2366s connection_factory = None, cursor_factory = None 2366s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2366s kwasync = {} 2366s 2366s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2366s """ 2366s Create a new database connection. 2366s 2366s The connection parameters can be specified as a string: 2366s 2366s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2366s 2366s or using a set of keyword arguments: 2366s 2366s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2366s 2366s Or as a mix of both. The basic connection parameters are: 2366s 2366s - *dbname*: the database name 2366s - *database*: the database name (only as keyword argument) 2366s - *user*: user name used to authenticate 2366s - *password*: password used to authenticate 2366s - *host*: database host address (defaults to UNIX socket if not provided) 2366s - *port*: connection port number (defaults to 5432 if not provided) 2366s 2366s Using the *connection_factory* parameter a different class or connections 2366s factory can be specified. It should be a callable object taking a dsn 2366s argument. 2366s 2366s Using the *cursor_factory* parameter, a new default cursor factory will be 2366s used by cursor(). 2366s 2366s Using *async*=True an asynchronous connection will be created. *async_* is 2366s a valid alias (for Python versions where ``async`` is a keyword). 2366s 2366s Any other keyword parameter will be passed to the underlying client 2366s library: the list of supported parameters depends on the library version. 2366s 2366s """ 2366s kwasync = {} 2366s if 'async' in kwargs: 2366s kwasync['async'] = kwargs.pop('async') 2366s if 'async_' in kwargs: 2366s kwasync['async_'] = kwargs.pop('async_') 2366s 2366s dsn = _ext.make_dsn(dsn, **kwargs) 2366s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2366s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2366s E Is the server running on that host and accepting TCP/IP connections? 2366s 2366s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2366s 2366s The above exception was the direct cause of the following exception: 2366s 2366s @pytest.fixture 2366s def postgresql_psycopg2_engine(): 2366s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2366s td.versioned_importorskip("psycopg2") 2366s engine = sqlalchemy.create_engine( 2366s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2366s poolclass=sqlalchemy.pool.NullPool, 2366s ) 2366s yield engine 2366s > for view in get_all_views(engine): 2366s 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2366s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2366s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2366s return inspect(conn).get_view_names() 2366s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2366s ret = reg(subject) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2366s return Inspector._construct(Inspector._init_engine, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2366s init(self, bind) 2366s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_api_read_sql_duplicate_columns[mysql_pymysql_engine] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_api_read_sql_duplicate_columns[mysql_pymysql_conn] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_api_read_sql_duplicate_columns[postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_api_read_sql_duplicate_columns[postgresql_psycopg2_conn] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ______ ERROR at teardown of test_read_table_columns[mysql_pymysql_engine] ______ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _______ ERROR at teardown of test_read_table_columns[mysql_pymysql_conn] _______ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s ___ ERROR at teardown of test_read_table_columns[postgresql_psycopg2_engine] ___ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ____ ERROR at teardown of test_read_table_columns[postgresql_psycopg2_conn] ____ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _____ ERROR at teardown of test_read_table_index_col[mysql_pymysql_engine] _____ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s ______ ERROR at teardown of test_read_table_index_col[mysql_pymysql_conn] ______ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s __ ERROR at teardown of test_read_table_index_col[postgresql_psycopg2_engine] __ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ___ ERROR at teardown of test_read_table_index_col[postgresql_psycopg2_conn] ___ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ____ ERROR at teardown of test_read_sql_delegate[mysql_pymysql_engine_iris] ____ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _____ ERROR at teardown of test_read_sql_delegate[mysql_pymysql_conn_iris] _____ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_read_sql_delegate[postgresql_psycopg2_engine_iris] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s __ ERROR at teardown of test_read_sql_delegate[postgresql_psycopg2_conn_iris] __ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_warning_case_insensitive_table_name[mysql_pymysql_engine] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_warning_case_insensitive_table_name[mysql_pymysql_conn] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_warning_case_insensitive_table_name[postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_warning_case_insensitive_table_name[postgresql_psycopg2_conn] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ___ ERROR at teardown of test_sqlalchemy_type_mapping[mysql_pymysql_engine] ____ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s ____ ERROR at teardown of test_sqlalchemy_type_mapping[mysql_pymysql_conn] _____ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_type_mapping[postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_type_mapping[postgresql_psycopg2_conn] __ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_engine] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_conn] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_conn] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_engine] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_conn] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_conn] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_engine] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_conn] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_conn] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_engine] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_conn] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_conn] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_engine] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_conn] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_conn] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_engine] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_conn] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_conn] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_engine] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_conn] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_conn] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_engine] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_conn] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_conn] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_engine] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_conn] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_conn] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_engine] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_conn] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_conn] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_engine] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_conn] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_conn] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_engine] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_conn] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_conn] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_engine] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_conn] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_conn] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_engine] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_conn] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_conn] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_engine] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_conn] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_conn] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_engine] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_conn] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_conn] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_engine] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_conn] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_conn] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _____ ERROR at teardown of test_database_uri_string[mysql_pymysql_engine] ______ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s ______ ERROR at teardown of test_database_uri_string[mysql_pymysql_conn] _______ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s __ ERROR at teardown of test_database_uri_string[postgresql_psycopg2_engine] ___ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ___ ERROR at teardown of test_database_uri_string[postgresql_psycopg2_conn] ____ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_engine] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_conn] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_conn] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ____ ERROR at teardown of test_query_by_text_obj[mysql_pymysql_engine_iris] ____ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _____ ERROR at teardown of test_query_by_text_obj[mysql_pymysql_conn_iris] _____ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_query_by_text_obj[postgresql_psycopg2_engine_iris] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s __ ERROR at teardown of test_query_by_text_obj[postgresql_psycopg2_conn_iris] __ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ___ ERROR at teardown of test_query_by_select_obj[mysql_pymysql_engine_iris] ___ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s ____ ERROR at teardown of test_query_by_select_obj[mysql_pymysql_conn_iris] ____ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_query_by_select_obj[postgresql_psycopg2_engine_iris] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_query_by_select_obj[postgresql_psycopg2_conn_iris] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ____ ERROR at teardown of test_column_with_percentage[mysql_pymysql_engine] ____ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _____ ERROR at teardown of test_column_with_percentage[mysql_pymysql_conn] _____ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_column_with_percentage[postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s __ ERROR at teardown of test_column_with_percentage[postgresql_psycopg2_conn] __ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _________ ERROR at teardown of test_create_table[mysql_pymysql_engine] _________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s __________ ERROR at teardown of test_create_table[mysql_pymysql_conn] __________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s ______ ERROR at teardown of test_create_table[postgresql_psycopg2_engine] ______ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _______ ERROR at teardown of test_create_table[postgresql_psycopg2_conn] _______ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s __________ ERROR at teardown of test_drop_table[mysql_pymysql_engine] __________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s ___________ ERROR at teardown of test_drop_table[mysql_pymysql_conn] ___________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _______ ERROR at teardown of test_drop_table[postgresql_psycopg2_engine] _______ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ________ ERROR at teardown of test_drop_table[postgresql_psycopg2_conn] ________ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s __________ ERROR at teardown of test_roundtrip[mysql_pymysql_engine] ___________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s ___________ ERROR at teardown of test_roundtrip[mysql_pymysql_conn] ____________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _______ ERROR at teardown of test_roundtrip[postgresql_psycopg2_engine] ________ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ________ ERROR at teardown of test_roundtrip[postgresql_psycopg2_conn] _________ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _______ ERROR at teardown of test_execute_sql[mysql_pymysql_engine_iris] _______ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s ________ ERROR at teardown of test_execute_sql[mysql_pymysql_conn_iris] ________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s ____ ERROR at teardown of test_execute_sql[postgresql_psycopg2_engine_iris] ____ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _____ ERROR at teardown of test_execute_sql[postgresql_psycopg2_conn_iris] _____ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s __ ERROR at teardown of test_sqlalchemy_read_table[mysql_pymysql_engine_iris] __ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s ___ ERROR at teardown of test_sqlalchemy_read_table[mysql_pymysql_conn_iris] ___ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_read_table[postgresql_psycopg2_engine_iris] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_read_table[postgresql_psycopg2_conn_iris] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_read_table_columns[mysql_pymysql_engine_iris] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_read_table_columns[mysql_pymysql_conn_iris] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_read_table_columns[postgresql_psycopg2_engine_iris] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_read_table_columns[postgresql_psycopg2_conn_iris] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_read_table_absent_raises[mysql_pymysql_engine_iris] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_read_table_absent_raises[mysql_pymysql_conn_iris] __ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_read_table_absent_raises[postgresql_psycopg2_engine_iris] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_read_table_absent_raises[postgresql_psycopg2_conn_iris] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_default_type_conversion[postgresql_psycopg2_engine_types] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_sqlalchemy_default_type_conversion[postgresql_psycopg2_conn_types] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ____________ ERROR at teardown of test_bigint[mysql_pymysql_engine] ____________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _____________ ERROR at teardown of test_bigint[mysql_pymysql_conn] _____________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _________ ERROR at teardown of test_bigint[postgresql_psycopg2_engine] _________ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s __________ ERROR at teardown of test_bigint[postgresql_psycopg2_conn] __________ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ___ ERROR at teardown of test_default_date_load[mysql_pymysql_engine_types] ____ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s ____ ERROR at teardown of test_default_date_load[mysql_pymysql_conn_types] _____ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_default_date_load[postgresql_psycopg2_engine_types] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_default_date_load[postgresql_psycopg2_conn_types] __ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_datetime_with_timezone_query[None-postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_datetime_with_timezone_query[None-postgresql_psycopg2_conn] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_conn] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_conn] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_datetime_with_timezone_table[postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_datetime_with_timezone_table[postgresql_psycopg2_conn] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_datetime_with_timezone_roundtrip[mysql_pymysql_engine] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_datetime_with_timezone_roundtrip[mysql_pymysql_conn] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_datetime_with_timezone_roundtrip[postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_datetime_with_timezone_roundtrip[postgresql_psycopg2_conn] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ____ ERROR at teardown of test_out_of_bounds_datetime[mysql_pymysql_engine] ____ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _____ ERROR at teardown of test_out_of_bounds_datetime[mysql_pymysql_conn] _____ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_out_of_bounds_datetime[postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s __ ERROR at teardown of test_out_of_bounds_datetime[postgresql_psycopg2_conn] __ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_naive_datetimeindex_roundtrip[mysql_pymysql_engine] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_naive_datetimeindex_roundtrip[mysql_pymysql_conn] __ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_naive_datetimeindex_roundtrip[postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_naive_datetimeindex_roundtrip[postgresql_psycopg2_conn] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ______ ERROR at teardown of test_date_parsing[mysql_pymysql_engine_types] ______ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _______ ERROR at teardown of test_date_parsing[mysql_pymysql_conn_types] _______ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s ___ ERROR at teardown of test_date_parsing[postgresql_psycopg2_engine_types] ___ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ____ ERROR at teardown of test_date_parsing[postgresql_psycopg2_conn_types] ____ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ___________ ERROR at teardown of test_datetime[mysql_pymysql_engine] ___________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s ____________ ERROR at teardown of test_datetime[mysql_pymysql_conn] ____________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s ________ ERROR at teardown of test_datetime[postgresql_psycopg2_engine] ________ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _________ ERROR at teardown of test_datetime[postgresql_psycopg2_conn] _________ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _________ ERROR at teardown of test_datetime_NaT[mysql_pymysql_engine] _________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s __________ ERROR at teardown of test_datetime_NaT[mysql_pymysql_conn] __________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s ______ ERROR at teardown of test_datetime_NaT[postgresql_psycopg2_engine] ______ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _______ ERROR at teardown of test_datetime_NaT[postgresql_psycopg2_conn] _______ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ________ ERROR at teardown of test_datetime_date[mysql_pymysql_engine] _________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _________ ERROR at teardown of test_datetime_date[mysql_pymysql_conn] __________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _____ ERROR at teardown of test_datetime_date[postgresql_psycopg2_engine] ______ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ______ ERROR at teardown of test_datetime_date[postgresql_psycopg2_conn] _______ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ________ ERROR at teardown of test_datetime_time[mysql_pymysql_engine] _________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _________ ERROR at teardown of test_datetime_time[mysql_pymysql_conn] __________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _____ ERROR at teardown of test_datetime_time[postgresql_psycopg2_engine] ______ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ______ ERROR at teardown of test_datetime_time[postgresql_psycopg2_conn] _______ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ______ ERROR at teardown of test_mixed_dtype_insert[mysql_pymysql_engine] ______ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _______ ERROR at teardown of test_mixed_dtype_insert[mysql_pymysql_conn] _______ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s ___ ERROR at teardown of test_mixed_dtype_insert[postgresql_psycopg2_engine] ___ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ____ ERROR at teardown of test_mixed_dtype_insert[postgresql_psycopg2_conn] ____ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _________ ERROR at teardown of test_nan_numeric[mysql_pymysql_engine] __________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s __________ ERROR at teardown of test_nan_numeric[mysql_pymysql_conn] ___________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s ______ ERROR at teardown of test_nan_numeric[postgresql_psycopg2_engine] _______ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _______ ERROR at teardown of test_nan_numeric[postgresql_psycopg2_conn] ________ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ________ ERROR at teardown of test_nan_fullcolumn[mysql_pymysql_engine] ________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _________ ERROR at teardown of test_nan_fullcolumn[mysql_pymysql_conn] _________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _____ ERROR at teardown of test_nan_fullcolumn[postgresql_psycopg2_engine] _____ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ______ ERROR at teardown of test_nan_fullcolumn[postgresql_psycopg2_conn] ______ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s __________ ERROR at teardown of test_nan_string[mysql_pymysql_engine] __________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s ___________ ERROR at teardown of test_nan_string[mysql_pymysql_conn] ___________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _______ ERROR at teardown of test_nan_string[postgresql_psycopg2_engine] _______ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ________ ERROR at teardown of test_nan_string[postgresql_psycopg2_conn] ________ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ______ ERROR at teardown of test_to_sql_save_index[mysql_pymysql_engine] _______ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _______ ERROR at teardown of test_to_sql_save_index[mysql_pymysql_conn] ________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s ___ ERROR at teardown of test_to_sql_save_index[postgresql_psycopg2_engine] ____ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ____ ERROR at teardown of test_to_sql_save_index[postgresql_psycopg2_conn] _____ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _________ ERROR at teardown of test_transactions[mysql_pymysql_engine] _________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s __________ ERROR at teardown of test_transactions[mysql_pymysql_conn] __________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s ______ ERROR at teardown of test_transactions[postgresql_psycopg2_engine] ______ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _______ ERROR at teardown of test_transactions[postgresql_psycopg2_conn] _______ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _____ ERROR at teardown of test_transaction_rollback[mysql_pymysql_engine] _____ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s ______ ERROR at teardown of test_transaction_rollback[mysql_pymysql_conn] ______ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s __ ERROR at teardown of test_transaction_rollback[postgresql_psycopg2_engine] __ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ___ ERROR at teardown of test_transaction_rollback[postgresql_psycopg2_conn] ___ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ___ ERROR at teardown of test_get_schema_create_table[mysql_pymysql_engine] ____ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s ____ ERROR at teardown of test_get_schema_create_table[mysql_pymysql_conn] _____ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_get_schema_create_table[postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_get_schema_create_table[postgresql_psycopg2_conn] __ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s ____________ ERROR at teardown of test_dtype[mysql_pymysql_engine] _____________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _____________ ERROR at teardown of test_dtype[mysql_pymysql_conn] ______________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _________ ERROR at teardown of test_dtype[postgresql_psycopg2_engine] __________ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s __________ ERROR at teardown of test_dtype[postgresql_psycopg2_conn] ___________ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _________ ERROR at teardown of test_notna_dtype[mysql_pymysql_engine] __________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s __________ ERROR at teardown of test_notna_dtype[mysql_pymysql_conn] ___________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s ______ ERROR at teardown of test_notna_dtype[postgresql_psycopg2_engine] _______ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _______ ERROR at teardown of test_notna_dtype[postgresql_psycopg2_conn] ________ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _______ ERROR at teardown of test_double_precision[mysql_pymysql_engine] _______ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s ________ ERROR at teardown of test_double_precision[mysql_pymysql_conn] ________ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s ____ ERROR at teardown of test_double_precision[postgresql_psycopg2_engine] ____ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _____ ERROR at teardown of test_double_precision[postgresql_psycopg2_conn] _____ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s __ ERROR at teardown of test_connectable_issue_example[mysql_pymysql_engine] ___ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s ___ ERROR at teardown of test_connectable_issue_example[mysql_pymysql_conn] ____ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_connectable_issue_example[postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_connectable_issue_example[postgresql_psycopg2_conn] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_to_sql_with_negative_npinf[input0-mysql_pymysql_engine] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_to_sql_with_negative_npinf[input0-mysql_pymysql_conn] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s _ ERROR at teardown of test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_engine] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_conn] _ 2367s self = 2367s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2367s connection = None, _has_events = None, _allow_revalidate = True 2367s _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def postgresql_psycopg2_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s td.versioned_importorskip("psycopg2") 2367s engine = sqlalchemy.create_engine( 2367s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2367s connection_factory = None, cursor_factory = None 2367s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2367s kwasync = {} 2367s 2367s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2367s """ 2367s Create a new database connection. 2367s 2367s The connection parameters can be specified as a string: 2367s 2367s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2367s 2367s or using a set of keyword arguments: 2367s 2367s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2367s 2367s Or as a mix of both. The basic connection parameters are: 2367s 2367s - *dbname*: the database name 2367s - *database*: the database name (only as keyword argument) 2367s - *user*: user name used to authenticate 2367s - *password*: password used to authenticate 2367s - *host*: database host address (defaults to UNIX socket if not provided) 2367s - *port*: connection port number (defaults to 5432 if not provided) 2367s 2367s Using the *connection_factory* parameter a different class or connections 2367s factory can be specified. It should be a callable object taking a dsn 2367s argument. 2367s 2367s Using the *cursor_factory* parameter, a new default cursor factory will be 2367s used by cursor(). 2367s 2367s Using *async*=True an asynchronous connection will be created. *async_* is 2367s a valid alias (for Python versions where ``async`` is a keyword). 2367s 2367s Any other keyword parameter will be passed to the underlying client 2367s library: the list of supported parameters depends on the library version. 2367s 2367s """ 2367s kwasync = {} 2367s if 'async' in kwargs: 2367s kwasync['async'] = kwargs.pop('async') 2367s if 'async_' in kwargs: 2367s kwasync['async_'] = kwargs.pop('async_') 2367s 2367s dsn = _ext.make_dsn(dsn, **kwargs) 2367s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2367s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2367s E Is the server running on that host and accepting TCP/IP connections? 2367s E 2367s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2367s 2367s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2367s _ ERROR at teardown of test_to_sql_with_negative_npinf[input1-mysql_pymysql_engine] _ 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s > sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3.13/socket.py:864: in create_connection 2367s raise exceptions[0] 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s address = ('localhost', 3306), timeout = 10, source_address = None 2367s 2367s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2367s source_address=None, *, all_errors=False): 2367s """Connect to *address* and return the socket object. 2367s 2367s Convenience function. Connect to *address* (a 2-tuple ``(host, 2367s port)``) and return the socket object. Passing the optional 2367s *timeout* parameter will set the timeout on the socket instance 2367s before attempting to connect. If no *timeout* is supplied, the 2367s global default timeout setting returned by :func:`getdefaulttimeout` 2367s is used. If *source_address* is set it must be a tuple of (host, port) 2367s for the socket to bind as a source address before making the connection. 2367s A host of '' or port 0 tells the OS to use the default. When a connection 2367s cannot be created, raises the last error if *all_errors* is False, 2367s and an ExceptionGroup of all errors if *all_errors* is True. 2367s """ 2367s 2367s host, port = address 2367s exceptions = [] 2367s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2367s af, socktype, proto, canonname, sa = res 2367s sock = None 2367s try: 2367s sock = socket(af, socktype, proto) 2367s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2367s sock.settimeout(timeout) 2367s if source_address: 2367s sock.bind(source_address) 2367s > sock.connect(sa) 2367s E ConnectionRefusedError: [Errno 111] Connection refused 2367s 2367s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2367s 2367s During handling of the above exception, another exception occurred: 2367s 2367s self = 2367s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2367s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2367s 2367s def __init__( 2367s self, 2367s engine: Engine, 2367s connection: Optional[PoolProxiedConnection] = None, 2367s _has_events: Optional[bool] = None, 2367s _allow_revalidate: bool = True, 2367s _allow_autobegin: bool = True, 2367s ): 2367s """Construct a new Connection.""" 2367s self.engine = engine 2367s self.dialect = dialect = engine.dialect 2367s 2367s if connection is None: 2367s try: 2367s > self._dbapi_connection = engine.raw_connection() 2367s 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2367s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2367s sock.settimeout(None) 2367s 2367s self._sock = sock 2367s self._rfile = sock.makefile("rb") 2367s self._next_seq_id = 0 2367s 2367s self._get_server_information() 2367s self._request_authentication() 2367s 2367s # Send "SET NAMES" query on init for: 2367s # - Ensure charaset (and collation) is set to the server. 2367s # - collation_id in handshake packet may be ignored. 2367s # - If collation is not specified, we don't know what is server's 2367s # default collation for the charset. For example, default collation 2367s # of utf8mb4 is: 2367s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2367s # - MySQL 8.0: utf8mb4_0900_ai_ci 2367s # 2367s # Reference: 2367s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2367s # - https://github.com/wagtail/wagtail/issues/9477 2367s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2367s self.set_character_set(self.charset, self.collation) 2367s 2367s if self.sql_mode is not None: 2367s c = self.cursor() 2367s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2367s c.close() 2367s 2367s if self.init_command is not None: 2367s c = self.cursor() 2367s c.execute(self.init_command) 2367s c.close() 2367s 2367s if self.autocommit_mode is not None: 2367s self.autocommit(self.autocommit_mode) 2367s except BaseException as e: 2367s self._rfile = None 2367s if sock is not None: 2367s try: 2367s sock.close() 2367s except: # noqa 2367s pass 2367s 2367s if isinstance(e, (OSError, IOError)): 2367s exc = err.OperationalError( 2367s CR.CR_CONN_HOST_ERROR, 2367s f"Can't connect to MySQL server on {self.host!r} ({e})", 2367s ) 2367s # Keep original exception and traceback to investigate error. 2367s exc.original_exception = e 2367s exc.traceback = traceback.format_exc() 2367s if DEBUG: 2367s print(exc.traceback) 2367s > raise exc 2367s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2367s 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2367s 2367s The above exception was the direct cause of the following exception: 2367s 2367s @pytest.fixture 2367s def mysql_pymysql_engine(): 2367s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2367s pymysql = td.versioned_importorskip("pymysql") 2367s engine = sqlalchemy.create_engine( 2367s "mysql+pymysql://root@localhost:3306/pandas", 2367s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2367s poolclass=sqlalchemy.pool.NullPool, 2367s ) 2367s yield engine 2367s > for view in get_all_views(engine): 2367s 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2367s return inspect(conn).get_view_names() 2367s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2367s ret = reg(subject) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2367s return Inspector._construct(Inspector._init_engine, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2367s init(self, bind) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2367s engine.connect().close() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2367s return self._connection_cls(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2367s Connection._handle_dbapi_exception_noconnection( 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2367s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2367s self._dbapi_connection = engine.raw_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2367s return self.pool.connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2367s return _ConnectionFairy._checkout(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2367s fairy = _ConnectionRecord.checkout(pool) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2367s rec = pool._do_get() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2367s return self._create_connection() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2367s return _ConnectionRecord(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2367s self.__connect() 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2367s with util.safe_reraise(): 2367s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2367s raise exc_value.with_traceback(exc_tb) 2367s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2367s self.dbapi_connection = connection = pool._invoke_creator(self) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2367s return dialect.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2367s return self.loaded_dbapi.connect(*cargs, **cparams) 2367s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2367s self.connect() 2367s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2367s 2367s self = , sock = None 2367s 2367s def connect(self, sock=None): 2367s self._closed = False 2367s try: 2367s if sock is None: 2367s if self.unix_socket: 2367s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2367s sock.settimeout(self.connect_timeout) 2367s sock.connect(self.unix_socket) 2367s self.host_info = "Localhost via UNIX socket" 2367s self._secure = True 2367s if DEBUG: 2367s print("connected using unix_socket") 2367s else: 2367s kwargs = {} 2367s if self.bind_address is not None: 2367s kwargs["source_address"] = (self.bind_address, 0) 2367s while True: 2367s try: 2367s sock = socket.create_connection( 2367s (self.host, self.port), self.connect_timeout, **kwargs 2367s ) 2367s break 2367s except OSError as e: 2367s if e.errno == errno.EINTR: 2367s continue 2367s raise 2367s self.host_info = "socket %s:%d" % (self.host, self.port) 2367s if DEBUG: 2367s print("connected using socket") 2367s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ ERROR at teardown of test_to_sql_with_negative_npinf[input1-mysql_pymysql_conn] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ ERROR at teardown of test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_engine] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ ERROR at teardown of test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_conn] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ ERROR at teardown of test_to_sql_with_negative_npinf[input2-mysql_pymysql_engine] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ ERROR at teardown of test_to_sql_with_negative_npinf[input2-mysql_pymysql_conn] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ ERROR at teardown of test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_engine] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ ERROR at teardown of test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_conn] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _______ ERROR at teardown of test_temporary_table[mysql_pymysql_engine] ________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ________ ERROR at teardown of test_temporary_table[mysql_pymysql_conn] _________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ____ ERROR at teardown of test_temporary_table[postgresql_psycopg2_engine] _____ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _____ ERROR at teardown of test_temporary_table[postgresql_psycopg2_conn] ______ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ________ ERROR at teardown of test_invalid_engine[mysql_pymysql_engine] ________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _________ ERROR at teardown of test_invalid_engine[mysql_pymysql_conn] _________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _____ ERROR at teardown of test_invalid_engine[postgresql_psycopg2_engine] _____ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ______ ERROR at teardown of test_invalid_engine[postgresql_psycopg2_conn] ______ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ____ ERROR at teardown of test_to_sql_with_sql_engine[mysql_pymysql_engine] ____ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _____ ERROR at teardown of test_to_sql_with_sql_engine[mysql_pymysql_conn] _____ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ ERROR at teardown of test_to_sql_with_sql_engine[postgresql_psycopg2_engine] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s __ ERROR at teardown of test_to_sql_with_sql_engine[postgresql_psycopg2_conn] __ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ______ ERROR at teardown of test_options_sqlalchemy[mysql_pymysql_engine] ______ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _______ ERROR at teardown of test_options_sqlalchemy[mysql_pymysql_conn] _______ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ___ ERROR at teardown of test_options_sqlalchemy[postgresql_psycopg2_engine] ___ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ____ ERROR at teardown of test_options_sqlalchemy[postgresql_psycopg2_conn] ____ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _________ ERROR at teardown of test_options_auto[mysql_pymysql_engine] _________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s __________ ERROR at teardown of test_options_auto[mysql_pymysql_conn] __________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ______ ERROR at teardown of test_options_auto[postgresql_psycopg2_engine] ______ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _______ ERROR at teardown of test_options_auto[postgresql_psycopg2_conn] _______ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_engine] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_conn] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_engine] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_conn] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_engine] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_conn] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_engine] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_conn] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_engine] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_conn] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_engine] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_conn] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_engine] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_conn] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_engine] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_conn] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_engine] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_conn] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_engine] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_conn] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_engine] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_conn] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_engine] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_conn] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ____ ERROR at teardown of test_chunksize_empty_dtypes[mysql_pymysql_engine] ____ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _____ ERROR at teardown of test_chunksize_empty_dtypes[mysql_pymysql_conn] _____ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ ERROR at teardown of test_chunksize_empty_dtypes[postgresql_psycopg2_engine] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s __ ERROR at teardown of test_chunksize_empty_dtypes[postgresql_psycopg2_conn] __ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_engine] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_conn] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_engine] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_conn] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_engine] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_conn] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_engine] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_conn] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_engine] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_conn] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_engine] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_conn] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_engine] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_conn] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def mysql_pymysql_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s pymysql = td.versioned_importorskip("pymysql") 2368s engine = sqlalchemy.create_engine( 2368s "mysql+pymysql://root@localhost:3306/pandas", 2368s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_engine] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_conn] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ______________ ERROR at teardown of test_psycopg2_schema_support _______________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _______________ ERROR at teardown of test_self_join_date_columns _______________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s @pytest.fixture 2368s def postgresql_psycopg2_engine(): 2368s sqlalchemy = td.versioned_importorskip("sqlalchemy") 2368s td.versioned_importorskip("psycopg2") 2368s engine = sqlalchemy.create_engine( 2368s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 2368s poolclass=sqlalchemy.pool.NullPool, 2368s ) 2368s yield engine 2368s > for view in get_all_views(engine): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 2368s return inspect(conn).get_view_names() 2368s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 2368s ret = reg(subject) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 2368s return Inspector._construct(Inspector._init_engine, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 2368s init(self, bind) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 2368s engine.connect().close() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s =================================== FAILURES =================================== 2368s _________________ test_dataframe_to_sql[mysql_pymysql_engine] __________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_dataframe_to_sql(conn, test_frame1, request): 2368s # GH 51086 if conn is sqlite_engine 2368s conn = request.getfixturevalue(conn) 2368s > test_frame1.to_sql(name="test", con=conn, if_exists="append", index=False) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:983: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2368s return func(*args, **kwargs) 2368s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2368s return sql.to_sql( 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2368s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s __________________ test_dataframe_to_sql[mysql_pymysql_conn] ___________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_dataframe_to_sql(conn, test_frame1, request): 2368s # GH 51086 if conn is sqlite_engine 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:982: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ______________ test_dataframe_to_sql[postgresql_psycopg2_engine] _______________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_dataframe_to_sql(conn, test_frame1, request): 2368s # GH 51086 if conn is sqlite_engine 2368s conn = request.getfixturevalue(conn) 2368s > test_frame1.to_sql(name="test", con=conn, if_exists="append", index=False) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:983: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2368s return func(*args, **kwargs) 2368s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2368s return sql.to_sql( 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2368s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _______________ test_dataframe_to_sql[postgresql_psycopg2_conn] ________________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_dataframe_to_sql(conn, test_frame1, request): 2368s # GH 51086 if conn is sqlite_engine 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:982: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ______________ test_dataframe_to_sql_empty[mysql_pymysql_engine] _______________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_dataframe_to_sql_empty(conn, test_frame1, request): 2368s if conn == "postgresql_adbc_conn": 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="postgres ADBC driver cannot insert index with null type", 2368s strict=True, 2368s ) 2368s ) 2368s # GH 51086 if conn is sqlite_engine 2368s conn = request.getfixturevalue(conn) 2368s empty_df = test_frame1.iloc[:0] 2368s > empty_df.to_sql(name="test", con=conn, if_exists="append", index=False) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:998: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2368s return func(*args, **kwargs) 2368s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2368s return sql.to_sql( 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2368s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _______________ test_dataframe_to_sql_empty[mysql_pymysql_conn] ________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_dataframe_to_sql_empty(conn, test_frame1, request): 2368s if conn == "postgresql_adbc_conn": 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="postgres ADBC driver cannot insert index with null type", 2368s strict=True, 2368s ) 2368s ) 2368s # GH 51086 if conn is sqlite_engine 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:996: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ___________ test_dataframe_to_sql_empty[postgresql_psycopg2_engine] ____________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_dataframe_to_sql_empty(conn, test_frame1, request): 2368s if conn == "postgresql_adbc_conn": 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="postgres ADBC driver cannot insert index with null type", 2368s strict=True, 2368s ) 2368s ) 2368s # GH 51086 if conn is sqlite_engine 2368s conn = request.getfixturevalue(conn) 2368s empty_df = test_frame1.iloc[:0] 2368s > empty_df.to_sql(name="test", con=conn, if_exists="append", index=False) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:998: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2368s return func(*args, **kwargs) 2368s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2368s return sql.to_sql( 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2368s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ____________ test_dataframe_to_sql_empty[postgresql_psycopg2_conn] _____________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_dataframe_to_sql_empty(conn, test_frame1, request): 2368s if conn == "postgresql_adbc_conn": 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="postgres ADBC driver cannot insert index with null type", 2368s strict=True, 2368s ) 2368s ) 2368s # GH 51086 if conn is sqlite_engine 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:996: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ____________________ test_to_sql[None-mysql_pymysql_engine] ____________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas), method = None 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize("method", [None, "multi"]) 2368s def test_to_sql(conn, method, test_frame1, request): 2368s if method == "multi" and "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'method' not implemented for ADBC drivers", strict=True 2368s ) 2368s ) 2368s 2368s conn = request.getfixturevalue(conn) 2368s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1061: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _____________________ test_to_sql[None-mysql_pymysql_conn] _____________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn', method = None 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize("method", [None, "multi"]) 2368s def test_to_sql(conn, method, test_frame1, request): 2368s if method == "multi" and "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'method' not implemented for ADBC drivers", strict=True 2368s ) 2368s ) 2368s 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1060: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _________________ test_to_sql[None-postgresql_psycopg2_engine] _________________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s method = None 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize("method", [None, "multi"]) 2368s def test_to_sql(conn, method, test_frame1, request): 2368s if method == "multi" and "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'method' not implemented for ADBC drivers", strict=True 2368s ) 2368s ) 2368s 2368s conn = request.getfixturevalue(conn) 2368s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1061: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s __________________ test_to_sql[None-postgresql_psycopg2_conn] __________________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn', method = None 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize("method", [None, "multi"]) 2368s def test_to_sql(conn, method, test_frame1, request): 2368s if method == "multi" and "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'method' not implemented for ADBC drivers", strict=True 2368s ) 2368s ) 2368s 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1060: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ___________________ test_to_sql[multi-mysql_pymysql_engine] ____________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas), method = 'multi' 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize("method", [None, "multi"]) 2368s def test_to_sql(conn, method, test_frame1, request): 2368s if method == "multi" and "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'method' not implemented for ADBC drivers", strict=True 2368s ) 2368s ) 2368s 2368s conn = request.getfixturevalue(conn) 2368s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1061: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ____________________ test_to_sql[multi-mysql_pymysql_conn] _____________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn', method = 'multi' 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize("method", [None, "multi"]) 2368s def test_to_sql(conn, method, test_frame1, request): 2368s if method == "multi" and "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'method' not implemented for ADBC drivers", strict=True 2368s ) 2368s ) 2368s 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1060: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ________________ test_to_sql[multi-postgresql_psycopg2_engine] _________________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s method = 'multi' 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize("method", [None, "multi"]) 2368s def test_to_sql(conn, method, test_frame1, request): 2368s if method == "multi" and "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'method' not implemented for ADBC drivers", strict=True 2368s ) 2368s ) 2368s 2368s conn = request.getfixturevalue(conn) 2368s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1061: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _________________ test_to_sql[multi-postgresql_psycopg2_conn] __________________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn', method = 'multi' 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize("method", [None, "multi"]) 2368s def test_to_sql(conn, method, test_frame1, request): 2368s if method == "multi" and "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'method' not implemented for ADBC drivers", strict=True 2368s ) 2368s ) 2368s 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1060: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ______________ test_to_sql_exist[replace-1-mysql_pymysql_engine] _______________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas), mode = 'replace' 2368s num_row_coef = 1 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2368s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2368s conn = request.getfixturevalue(conn) 2368s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1071: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _______________ test_to_sql_exist[replace-1-mysql_pymysql_conn] ________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn', mode = 'replace', num_row_coef = 1 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2368s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1070: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ___________ test_to_sql_exist[replace-1-postgresql_psycopg2_engine] ____________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s mode = 'replace', num_row_coef = 1 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2368s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2368s conn = request.getfixturevalue(conn) 2368s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1071: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ____________ test_to_sql_exist[replace-1-postgresql_psycopg2_conn] _____________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn', mode = 'replace', num_row_coef = 1 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2368s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1070: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _______________ test_to_sql_exist[append-2-mysql_pymysql_engine] _______________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas), mode = 'append' 2368s num_row_coef = 2 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2368s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2368s conn = request.getfixturevalue(conn) 2368s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1071: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ________________ test_to_sql_exist[append-2-mysql_pymysql_conn] ________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn', mode = 'append', num_row_coef = 2 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2368s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1070: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ____________ test_to_sql_exist[append-2-postgresql_psycopg2_engine] ____________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s mode = 'append', num_row_coef = 2 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2368s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2368s conn = request.getfixturevalue(conn) 2368s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1071: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _____________ test_to_sql_exist[append-2-postgresql_psycopg2_conn] _____________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn', mode = 'append', num_row_coef = 2 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 2368s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1070: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _________________ test_to_sql_exist_fail[mysql_pymysql_engine] _________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_to_sql_exist_fail(conn, test_frame1, request): 2368s conn = request.getfixturevalue(conn) 2368s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1081: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s __________________ test_to_sql_exist_fail[mysql_pymysql_conn] __________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_to_sql_exist_fail(conn, test_frame1, request): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1080: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ______________ test_to_sql_exist_fail[postgresql_psycopg2_engine] ______________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_to_sql_exist_fail(conn, test_frame1, request): 2368s conn = request.getfixturevalue(conn) 2368s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1081: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _______________ test_to_sql_exist_fail[postgresql_psycopg2_conn] _______________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_to_sql_exist_fail(conn, test_frame1, request): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1080: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _______________ test_read_iris_query[mysql_pymysql_engine_iris] ________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_engine_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_read_iris_query(conn, request): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1092: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2368s create_and_load_iris(mysql_pymysql_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ________________ test_read_iris_query[mysql_pymysql_conn_iris] _________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_read_iris_query(conn, request): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1092: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2368s create_and_load_iris(mysql_pymysql_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ____________ test_read_iris_query[postgresql_psycopg2_engine_iris] _____________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_engine_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_read_iris_query(conn, request): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1092: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2368s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _____________ test_read_iris_query[postgresql_psycopg2_conn_iris] ______________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_read_iris_query(conn, request): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1092: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2368s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s __________ test_read_iris_query_chunksize[mysql_pymysql_engine_iris] ___________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_engine_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_read_iris_query_chunksize(conn, request): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'chunksize' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1111: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2368s create_and_load_iris(mysql_pymysql_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ___________ test_read_iris_query_chunksize[mysql_pymysql_conn_iris] ____________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_read_iris_query_chunksize(conn, request): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'chunksize' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1111: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2368s create_and_load_iris(mysql_pymysql_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _______ test_read_iris_query_chunksize[postgresql_psycopg2_engine_iris] ________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_engine_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_read_iris_query_chunksize(conn, request): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'chunksize' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1111: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2368s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ________ test_read_iris_query_chunksize[postgresql_psycopg2_conn_iris] _________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_read_iris_query_chunksize(conn, request): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'chunksize' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1111: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2368s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s __ test_read_iris_query_expression_with_parameter[mysql_pymysql_engine_iris] ___ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_engine_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2368s def test_read_iris_query_expression_with_parameter(conn, request): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'chunksize' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1130: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2368s create_and_load_iris(mysql_pymysql_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ___ test_read_iris_query_expression_with_parameter[mysql_pymysql_conn_iris] ____ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2368s def test_read_iris_query_expression_with_parameter(conn, request): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'chunksize' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1130: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2368s create_and_load_iris(mysql_pymysql_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_read_iris_query_expression_with_parameter[postgresql_psycopg2_engine_iris] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_engine_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2368s def test_read_iris_query_expression_with_parameter(conn, request): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'chunksize' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1130: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2368s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_read_iris_query_expression_with_parameter[postgresql_psycopg2_conn_iris] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2368s def test_read_iris_query_expression_with_parameter(conn, request): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'chunksize' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1130: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2368s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ____ test_read_iris_query_string_with_parameter[mysql_pymysql_engine_iris] _____ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_engine_iris' 2368s request = > 2368s 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=?'}} 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_read_iris_query_string_with_parameter(conn, request, sql_strings): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'chunksize' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s 2368s for db, query in sql_strings["read_parameters"].items(): 2368s if db in conn: 2368s break 2368s else: 2368s raise KeyError(f"No part of {conn} found in sql_strings['read_parameters']") 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1164: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2368s create_and_load_iris(mysql_pymysql_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _____ test_read_iris_query_string_with_parameter[mysql_pymysql_conn_iris] ______ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn_iris' 2368s request = > 2368s 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=?'}} 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_read_iris_query_string_with_parameter(conn, request, sql_strings): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'chunksize' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s 2368s for db, query in sql_strings["read_parameters"].items(): 2368s if db in conn: 2368s break 2368s else: 2368s raise KeyError(f"No part of {conn} found in sql_strings['read_parameters']") 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1164: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2368s create_and_load_iris(mysql_pymysql_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_read_iris_query_string_with_parameter[postgresql_psycopg2_engine_iris] __ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_engine_iris' 2368s request = > 2368s 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=?'}} 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_read_iris_query_string_with_parameter(conn, request, sql_strings): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'chunksize' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s 2368s for db, query in sql_strings["read_parameters"].items(): 2368s if db in conn: 2368s break 2368s else: 2368s raise KeyError(f"No part of {conn} found in sql_strings['read_parameters']") 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1164: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2368s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s __ test_read_iris_query_string_with_parameter[postgresql_psycopg2_conn_iris] ___ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn_iris' 2368s request = > 2368s 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=?'}} 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_read_iris_query_string_with_parameter(conn, request, sql_strings): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'chunksize' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s 2368s for db, query in sql_strings["read_parameters"].items(): 2368s if db in conn: 2368s break 2368s else: 2368s raise KeyError(f"No part of {conn} found in sql_strings['read_parameters']") 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1164: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2368s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _______________ test_read_iris_table[mysql_pymysql_engine_iris] ________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_engine_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2368s def test_read_iris_table(conn, request): 2368s # GH 51015 if conn = sqlite_iris_str 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1172: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2368s create_and_load_iris(mysql_pymysql_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ________________ test_read_iris_table[mysql_pymysql_conn_iris] _________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2368s def test_read_iris_table(conn, request): 2368s # GH 51015 if conn = sqlite_iris_str 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1172: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2368s create_and_load_iris(mysql_pymysql_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ____________ test_read_iris_table[postgresql_psycopg2_engine_iris] _____________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_engine_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2368s def test_read_iris_table(conn, request): 2368s # GH 51015 if conn = sqlite_iris_str 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1172: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2368s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _____________ test_read_iris_table[postgresql_psycopg2_conn_iris] ______________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2368s def test_read_iris_table(conn, request): 2368s # GH 51015 if conn = sqlite_iris_str 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1172: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2368s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s __________ test_read_iris_table_chunksize[mysql_pymysql_engine_iris] ___________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_engine_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2368s def test_read_iris_table_chunksize(conn, request): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1185: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2368s create_and_load_iris(mysql_pymysql_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ___________ test_read_iris_table_chunksize[mysql_pymysql_conn_iris] ____________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2368s def test_read_iris_table_chunksize(conn, request): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1185: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2368s create_and_load_iris(mysql_pymysql_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _______ test_read_iris_table_chunksize[postgresql_psycopg2_engine_iris] ________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_engine_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2368s def test_read_iris_table_chunksize(conn, request): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1185: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2368s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ________ test_read_iris_table_chunksize[postgresql_psycopg2_conn_iris] _________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2368s def test_read_iris_table_chunksize(conn, request): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1185: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2368s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s __________________ test_to_sql_callable[mysql_pymysql_engine] __________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2368s def test_to_sql_callable(conn, test_frame1, request): 2368s conn = request.getfixturevalue(conn) 2368s 2368s check = [] # used to double check function below is really being used 2368s 2368s def sample(pd_table, conn, keys, data_iter): 2368s check.append(1) 2368s data = [dict(zip(keys, row)) for row in data_iter] 2368s conn.execute(pd_table.table.insert(), data) 2368s 2368s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1203: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ___________________ test_to_sql_callable[mysql_pymysql_conn] ___________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2368s def test_to_sql_callable(conn, test_frame1, request): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1194: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _______________ test_to_sql_callable[postgresql_psycopg2_engine] _______________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2368s def test_to_sql_callable(conn, test_frame1, request): 2368s conn = request.getfixturevalue(conn) 2368s 2368s check = [] # used to double check function below is really being used 2368s 2368s def sample(pd_table, conn, keys, data_iter): 2368s check.append(1) 2368s data = [dict(zip(keys, row)) for row in data_iter] 2368s conn.execute(pd_table.table.insert(), data) 2368s 2368s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1203: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ________________ test_to_sql_callable[postgresql_psycopg2_conn] ________________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2368s def test_to_sql_callable(conn, test_frame1, request): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1194: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ___________ test_default_type_conversion[mysql_pymysql_engine_types] ___________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_engine_types' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s def test_default_type_conversion(conn, request): 2368s conn_name = conn 2368s if conn_name == "sqlite_buildin_types": 2368s request.applymarker( 2368s pytest.mark.xfail( 2368s reason="sqlite_buildin connection does not implement read_sql_table" 2368s ) 2368s ) 2368s 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1220: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ____________ test_default_type_conversion[mysql_pymysql_conn_types] ____________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn_types' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s def test_default_type_conversion(conn, request): 2368s conn_name = conn 2368s if conn_name == "sqlite_buildin_types": 2368s request.applymarker( 2368s pytest.mark.xfail( 2368s reason="sqlite_buildin connection does not implement read_sql_table" 2368s ) 2368s ) 2368s 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1220: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ________ test_default_type_conversion[postgresql_psycopg2_engine_types] ________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_engine_types' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s def test_default_type_conversion(conn, request): 2368s conn_name = conn 2368s if conn_name == "sqlite_buildin_types": 2368s request.applymarker( 2368s pytest.mark.xfail( 2368s reason="sqlite_buildin connection does not implement read_sql_table" 2368s ) 2368s ) 2368s 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1220: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _________ test_default_type_conversion[postgresql_psycopg2_conn_types] _________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn_types' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s def test_default_type_conversion(conn, request): 2368s conn_name = conn 2368s if conn_name == "sqlite_buildin_types": 2368s request.applymarker( 2368s pytest.mark.xfail( 2368s reason="sqlite_buildin connection does not implement read_sql_table" 2368s ) 2368s ) 2368s 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1220: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s __________________ test_read_procedure[mysql_pymysql_engine] ___________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", mysql_connectable) 2368s def test_read_procedure(conn, request): 2368s conn = request.getfixturevalue(conn) 2368s 2368s # GH 7324 2368s # Although it is more an api test, it is added to the 2368s # mysql tests as sqlite does not have stored procedures 2368s from sqlalchemy import text 2368s from sqlalchemy.engine import Engine 2368s 2368s df = DataFrame({"a": [1, 2, 3], "b": [0.1, 0.2, 0.3]}) 2368s > df.to_sql(name="test_frame", con=conn, index=False) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1253: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2368s return func(*args, **kwargs) 2368s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2368s return sql.to_sql( 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2368s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ___________________ test_read_procedure[mysql_pymysql_conn] ____________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", mysql_connectable) 2368s def test_read_procedure(conn, request): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1244: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ____ test_copy_from_callable_insertion_method[2-postgresql_psycopg2_engine] ____ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s expected_count = 2 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", postgresql_connectable) 2368s @pytest.mark.parametrize("expected_count", [2, "Success!"]) 2368s def test_copy_from_callable_insertion_method(conn, expected_count, request): 2368s # GH 8953 2368s # Example in io.rst found under _io.sql.method 2368s # not available in sqlite, mysql 2368s def psql_insert_copy(table, conn, keys, data_iter): 2368s # gets a DBAPI connection that can provide a cursor 2368s dbapi_conn = conn.connection 2368s with dbapi_conn.cursor() as cur: 2368s s_buf = StringIO() 2368s writer = csv.writer(s_buf) 2368s writer.writerows(data_iter) 2368s s_buf.seek(0) 2368s 2368s columns = ", ".join([f'"{k}"' for k in keys]) 2368s if table.schema: 2368s table_name = f"{table.schema}.{table.name}" 2368s else: 2368s table_name = table.name 2368s 2368s sql_query = f"COPY {table_name} ({columns}) FROM STDIN WITH CSV" 2368s cur.copy_expert(sql=sql_query, file=s_buf) 2368s return expected_count 2368s 2368s conn = request.getfixturevalue(conn) 2368s expected = DataFrame({"col1": [1, 2], "col2": [0.1, 0.2], "col3": ["a", "n"]}) 2368s > result_count = expected.to_sql( 2368s name="test_frame", con=conn, index=False, method=psql_insert_copy 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1306: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2368s return func(*args, **kwargs) 2368s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2368s return sql.to_sql( 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2368s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _____ test_copy_from_callable_insertion_method[2-postgresql_psycopg2_conn] _____ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn', expected_count = 2 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", postgresql_connectable) 2368s @pytest.mark.parametrize("expected_count", [2, "Success!"]) 2368s def test_copy_from_callable_insertion_method(conn, expected_count, request): 2368s # GH 8953 2368s # Example in io.rst found under _io.sql.method 2368s # not available in sqlite, mysql 2368s def psql_insert_copy(table, conn, keys, data_iter): 2368s # gets a DBAPI connection that can provide a cursor 2368s dbapi_conn = conn.connection 2368s with dbapi_conn.cursor() as cur: 2368s s_buf = StringIO() 2368s writer = csv.writer(s_buf) 2368s writer.writerows(data_iter) 2368s s_buf.seek(0) 2368s 2368s columns = ", ".join([f'"{k}"' for k in keys]) 2368s if table.schema: 2368s table_name = f"{table.schema}.{table.name}" 2368s else: 2368s table_name = table.name 2368s 2368s sql_query = f"COPY {table_name} ({columns}) FROM STDIN WITH CSV" 2368s cur.copy_expert(sql=sql_query, file=s_buf) 2368s return expected_count 2368s 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1304: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_engine] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s expected_count = 'Success!' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", postgresql_connectable) 2368s @pytest.mark.parametrize("expected_count", [2, "Success!"]) 2368s def test_copy_from_callable_insertion_method(conn, expected_count, request): 2368s # GH 8953 2368s # Example in io.rst found under _io.sql.method 2368s # not available in sqlite, mysql 2368s def psql_insert_copy(table, conn, keys, data_iter): 2368s # gets a DBAPI connection that can provide a cursor 2368s dbapi_conn = conn.connection 2368s with dbapi_conn.cursor() as cur: 2368s s_buf = StringIO() 2368s writer = csv.writer(s_buf) 2368s writer.writerows(data_iter) 2368s s_buf.seek(0) 2368s 2368s columns = ", ".join([f'"{k}"' for k in keys]) 2368s if table.schema: 2368s table_name = f"{table.schema}.{table.name}" 2368s else: 2368s table_name = table.name 2368s 2368s sql_query = f"COPY {table_name} ({columns}) FROM STDIN WITH CSV" 2368s cur.copy_expert(sql=sql_query, file=s_buf) 2368s return expected_count 2368s 2368s conn = request.getfixturevalue(conn) 2368s expected = DataFrame({"col1": [1, 2], "col2": [0.1, 0.2], "col3": ["a", "n"]}) 2368s > result_count = expected.to_sql( 2368s name="test_frame", con=conn, index=False, method=psql_insert_copy 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1306: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2368s return func(*args, **kwargs) 2368s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2368s return sql.to_sql( 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2368s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_conn] __ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn', expected_count = 'Success!' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", postgresql_connectable) 2368s @pytest.mark.parametrize("expected_count", [2, "Success!"]) 2368s def test_copy_from_callable_insertion_method(conn, expected_count, request): 2368s # GH 8953 2368s # Example in io.rst found under _io.sql.method 2368s # not available in sqlite, mysql 2368s def psql_insert_copy(table, conn, keys, data_iter): 2368s # gets a DBAPI connection that can provide a cursor 2368s dbapi_conn = conn.connection 2368s with dbapi_conn.cursor() as cur: 2368s s_buf = StringIO() 2368s writer = csv.writer(s_buf) 2368s writer.writerows(data_iter) 2368s s_buf.seek(0) 2368s 2368s columns = ", ".join([f'"{k}"' for k in keys]) 2368s if table.schema: 2368s table_name = f"{table.schema}.{table.name}" 2368s else: 2368s table_name = table.name 2368s 2368s sql_query = f"COPY {table_name} ({columns}) FROM STDIN WITH CSV" 2368s cur.copy_expert(sql=sql_query, file=s_buf) 2368s return expected_count 2368s 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1304: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ___ test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_engine] ___ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", postgresql_connectable) 2368s def test_insertion_method_on_conflict_do_nothing(conn, request): 2368s # GH 15988: Example in to_sql docstring 2368s conn = request.getfixturevalue(conn) 2368s 2368s from sqlalchemy.dialects.postgresql import insert 2368s from sqlalchemy.engine import Engine 2368s from sqlalchemy.sql import text 2368s 2368s def insert_on_conflict(table, conn, keys, data_iter): 2368s data = [dict(zip(keys, row)) for row in data_iter] 2368s stmt = ( 2368s insert(table.table) 2368s .values(data) 2368s .on_conflict_do_nothing(index_elements=["a"]) 2368s ) 2368s result = conn.execute(stmt) 2368s return result.rowcount 2368s 2368s create_sql = text( 2368s """ 2368s CREATE TABLE test_insert_conflict ( 2368s a integer PRIMARY KEY, 2368s b numeric, 2368s c text 2368s ); 2368s """ 2368s ) 2368s if isinstance(conn, Engine): 2368s > with conn.connect() as con: 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1347: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ____ test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_conn] ____ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", postgresql_connectable) 2368s def test_insertion_method_on_conflict_do_nothing(conn, request): 2368s # GH 15988: Example in to_sql docstring 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1321: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ___________ test_to_sql_on_public_schema[postgresql_psycopg2_engine] ___________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_to_sql_on_public_schema(conn, request): 2368s if "sqlite" in conn or "mysql" in conn: 2368s request.applymarker( 2368s pytest.mark.xfail( 2368s reason="test for public schema only specific to postgresql" 2368s ) 2368s ) 2368s 2368s conn = request.getfixturevalue(conn) 2368s 2368s test_data = DataFrame([[1, 2.1, "a"], [2, 3.1, "b"]], columns=list("abc")) 2368s > test_data.to_sql( 2368s name="test_public_schema", 2368s con=conn, 2368s if_exists="append", 2368s index=False, 2368s schema="public", 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1388: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2368s return func(*args, **kwargs) 2368s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2368s return sql.to_sql( 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2368s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ____________ test_to_sql_on_public_schema[postgresql_psycopg2_conn] ____________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_to_sql_on_public_schema(conn, request): 2368s if "sqlite" in conn or "mysql" in conn: 2368s request.applymarker( 2368s pytest.mark.xfail( 2368s reason="test for public schema only specific to postgresql" 2368s ) 2368s ) 2368s 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1385: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ________ test_insertion_method_on_conflict_update[mysql_pymysql_engine] ________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", mysql_connectable) 2368s def test_insertion_method_on_conflict_update(conn, request): 2368s # GH 14553: Example in to_sql docstring 2368s conn = request.getfixturevalue(conn) 2368s 2368s from sqlalchemy.dialects.mysql import insert 2368s from sqlalchemy.engine import Engine 2368s from sqlalchemy.sql import text 2368s 2368s def insert_on_conflict(table, conn, keys, data_iter): 2368s data = [dict(zip(keys, row)) for row in data_iter] 2368s stmt = insert(table.table).values(data) 2368s stmt = stmt.on_duplicate_key_update(b=stmt.inserted.b, c=stmt.inserted.c) 2368s result = conn.execute(stmt) 2368s return result.rowcount 2368s 2368s create_sql = text( 2368s """ 2368s CREATE TABLE test_insert_conflict ( 2368s a INT PRIMARY KEY, 2368s b FLOAT, 2368s c VARCHAR(10) 2368s ); 2368s """ 2368s ) 2368s if isinstance(conn, Engine): 2368s > with conn.connect() as con: 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1426: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _________ test_insertion_method_on_conflict_update[mysql_pymysql_conn] _________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", mysql_connectable) 2368s def test_insertion_method_on_conflict_update(conn, request): 2368s # GH 14553: Example in to_sql docstring 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1403: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _____________ test_read_view_postgres[postgresql_psycopg2_engine] ______________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", postgresql_connectable) 2368s def test_read_view_postgres(conn, request): 2368s # GH 52969 2368s conn = request.getfixturevalue(conn) 2368s 2368s from sqlalchemy.engine import Engine 2368s from sqlalchemy.sql import text 2368s 2368s table_name = f"group_{uuid.uuid4().hex}" 2368s view_name = f"group_view_{uuid.uuid4().hex}" 2368s 2368s sql_stmt = text( 2368s f""" 2368s CREATE TABLE {table_name} ( 2368s group_id INTEGER, 2368s name TEXT 2368s ); 2368s INSERT INTO {table_name} VALUES 2368s (1, 'name'); 2368s CREATE VIEW {view_name} 2368s AS 2368s SELECT * FROM {table_name}; 2368s """ 2368s ) 2368s if isinstance(conn, Engine): 2368s > with conn.connect() as con: 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1478: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ______________ test_read_view_postgres[postgresql_psycopg2_conn] _______________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", postgresql_connectable) 2368s def test_read_view_postgres(conn, request): 2368s # GH 52969 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1456: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ___________ test_read_sql_iris_parameter[mysql_pymysql_engine_iris] ____________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_engine_iris' 2368s request = > 2368s 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=?'}} 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_read_sql_iris_parameter(conn, request, sql_strings): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'params' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1555: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2368s create_and_load_iris(mysql_pymysql_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ____________ test_read_sql_iris_parameter[mysql_pymysql_conn_iris] _____________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn_iris' 2368s request = > 2368s 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=?'}} 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_read_sql_iris_parameter(conn, request, sql_strings): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'params' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1555: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2368s create_and_load_iris(mysql_pymysql_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ________ test_read_sql_iris_parameter[postgresql_psycopg2_engine_iris] _________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_engine_iris' 2368s request = > 2368s 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=?'}} 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_read_sql_iris_parameter(conn, request, sql_strings): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'params' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1555: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2368s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _________ test_read_sql_iris_parameter[postgresql_psycopg2_conn_iris] __________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn_iris' 2368s request = > 2368s 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=?'}} 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_read_sql_iris_parameter(conn, request, sql_strings): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'params' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1555: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2368s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ________ test_read_sql_iris_named_parameter[mysql_pymysql_engine_iris] _________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_engine_iris' 2368s request = > 2368s 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=?'}} 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_read_sql_iris_named_parameter(conn, request, sql_strings): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'params' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1575: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2368s create_and_load_iris(mysql_pymysql_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _________ test_read_sql_iris_named_parameter[mysql_pymysql_conn_iris] __________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn_iris' 2368s request = > 2368s 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=?'}} 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_read_sql_iris_named_parameter(conn, request, sql_strings): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'params' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1575: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2368s create_and_load_iris(mysql_pymysql_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _____ test_read_sql_iris_named_parameter[postgresql_psycopg2_engine_iris] ______ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_engine_iris' 2368s request = > 2368s 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=?'}} 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_read_sql_iris_named_parameter(conn, request, sql_strings): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'params' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1575: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2368s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ______ test_read_sql_iris_named_parameter[postgresql_psycopg2_conn_iris] _______ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn_iris' 2368s request = > 2368s 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=?'}} 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_read_sql_iris_named_parameter(conn, request, sql_strings): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'params' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1575: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2368s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ______________ test_api_read_sql_view[mysql_pymysql_engine_iris] _______________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_engine_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_api_read_sql_view(conn, request): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1605: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2368s create_and_load_iris(mysql_pymysql_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _______________ test_api_read_sql_view[mysql_pymysql_conn_iris] ________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_api_read_sql_view(conn, request): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1605: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2368s create_and_load_iris(mysql_pymysql_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ___________ test_api_read_sql_view[postgresql_psycopg2_engine_iris] ____________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_engine_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_api_read_sql_view(conn, request): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1605: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2368s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ____________ test_api_read_sql_view[postgresql_psycopg2_conn_iris] _____________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_api_read_sql_view(conn, request): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1605: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2368s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ____ test_api_read_sql_with_chunksize_no_result[mysql_pymysql_engine_iris] _____ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_engine_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_api_read_sql_with_chunksize_no_result(conn, request): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1616: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2368s create_and_load_iris(mysql_pymysql_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _____ test_api_read_sql_with_chunksize_no_result[mysql_pymysql_conn_iris] ______ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_api_read_sql_with_chunksize_no_result(conn, request): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1616: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2368s create_and_load_iris(mysql_pymysql_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_engine_iris] __ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_engine_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_api_read_sql_with_chunksize_no_result(conn, request): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1616: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2368s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s __ test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_conn_iris] ___ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_api_read_sql_with_chunksize_no_result(conn, request): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1616: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2368s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ____________________ test_api_to_sql[mysql_pymysql_engine] _____________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_to_sql(conn, request, test_frame1): 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_frame1", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1626: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _____________________ test_api_to_sql[mysql_pymysql_conn] ______________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_to_sql(conn, request, test_frame1): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1625: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _________________ test_api_to_sql[postgresql_psycopg2_engine] __________________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_to_sql(conn, request, test_frame1): 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_frame1", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1626: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s __________________ test_api_to_sql[postgresql_psycopg2_conn] ___________________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_to_sql(conn, request, test_frame1): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1625: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s __________________ test_api_to_sql_fail[mysql_pymysql_engine] __________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_to_sql_fail(conn, request, test_frame1): 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_frame2", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1637: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ___________________ test_api_to_sql_fail[mysql_pymysql_conn] ___________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_to_sql_fail(conn, request, test_frame1): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1636: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _______________ test_api_to_sql_fail[postgresql_psycopg2_engine] _______________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_to_sql_fail(conn, request, test_frame1): 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_frame2", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1637: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ________________ test_api_to_sql_fail[postgresql_psycopg2_conn] ________________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_to_sql_fail(conn, request, test_frame1): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1636: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ________________ test_api_to_sql_replace[mysql_pymysql_engine] _________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_to_sql_replace(conn, request, test_frame1): 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_frame3", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1652: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _________________ test_api_to_sql_replace[mysql_pymysql_conn] __________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_to_sql_replace(conn, request, test_frame1): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1651: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _____________ test_api_to_sql_replace[postgresql_psycopg2_engine] ______________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_to_sql_replace(conn, request, test_frame1): 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_frame3", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1652: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ______________ test_api_to_sql_replace[postgresql_psycopg2_conn] _______________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_to_sql_replace(conn, request, test_frame1): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1651: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _________________ test_api_to_sql_append[mysql_pymysql_engine] _________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_to_sql_append(conn, request, test_frame1): 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_frame4", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1670: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s __________________ test_api_to_sql_append[mysql_pymysql_conn] __________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_to_sql_append(conn, request, test_frame1): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1669: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ______________ test_api_to_sql_append[postgresql_psycopg2_engine] ______________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_to_sql_append(conn, request, test_frame1): 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_frame4", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1670: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _______________ test_api_to_sql_append[postgresql_psycopg2_conn] _______________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_to_sql_append(conn, request, test_frame1): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1669: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ______________ test_api_to_sql_type_mapping[mysql_pymysql_engine] ______________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s request = > 2368s test_frame3 = index A B 2368s 0 2000-01-03 00:00:00 2147483647 -1.987670 2368s 1 2000-01-04 00:00:00 -29 -0.041232 2368s 2 2000-01-05 00:00:00 20000 0.731168 2368s 3 2000-01-06 00:00:00 -290867 1.567621 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_to_sql_type_mapping(conn, request, test_frame3): 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_frame5", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1689: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _______________ test_api_to_sql_type_mapping[mysql_pymysql_conn] _______________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s request = > 2368s test_frame3 = index A B 2368s 0 2000-01-03 00:00:00 2147483647 -1.987670 2368s 1 2000-01-04 00:00:00 -29 -0.041232 2368s 2 2000-01-05 00:00:00 20000 0.731168 2368s 3 2000-01-06 00:00:00 -290867 1.567621 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_to_sql_type_mapping(conn, request, test_frame3): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1688: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ___________ test_api_to_sql_type_mapping[postgresql_psycopg2_engine] ___________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s test_frame3 = index A B 2368s 0 2000-01-03 00:00:00 2147483647 -1.987670 2368s 1 2000-01-04 00:00:00 -29 -0.041232 2368s 2 2000-01-05 00:00:00 20000 0.731168 2368s 3 2000-01-06 00:00:00 -290867 1.567621 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_to_sql_type_mapping(conn, request, test_frame3): 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_frame5", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1689: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ____________ test_api_to_sql_type_mapping[postgresql_psycopg2_conn] ____________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s request = > 2368s test_frame3 = index A B 2368s 0 2000-01-03 00:00:00 2147483647 -1.987670 2368s 1 2000-01-04 00:00:00 -29 -0.041232 2368s 2 2000-01-05 00:00:00 20000 0.731168 2368s 3 2000-01-06 00:00:00 -290867 1.567621 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_to_sql_type_mapping(conn, request, test_frame3): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1688: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _________________ test_api_to_sql_series[mysql_pymysql_engine] _________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_to_sql_series(conn, request): 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_series", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1702: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s __________________ test_api_to_sql_series[mysql_pymysql_conn] __________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_to_sql_series(conn, request): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1701: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ______________ test_api_to_sql_series[postgresql_psycopg2_engine] ______________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_to_sql_series(conn, request): 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_series", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1702: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _______________ test_api_to_sql_series[postgresql_psycopg2_conn] _______________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_to_sql_series(conn, request): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1701: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ___________________ test_api_roundtrip[mysql_pymysql_engine] ___________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_roundtrip(conn, request, test_frame1): 2368s conn_name = conn 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_frame_roundtrip", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1716: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ____________________ test_api_roundtrip[mysql_pymysql_conn] ____________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_roundtrip(conn, request, test_frame1): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1715: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ________________ test_api_roundtrip[postgresql_psycopg2_engine] ________________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_roundtrip(conn, request, test_frame1): 2368s conn_name = conn 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_frame_roundtrip", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1716: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _________________ test_api_roundtrip[postgresql_psycopg2_conn] _________________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_roundtrip(conn, request, test_frame1): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1715: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ______________ test_api_roundtrip_chunksize[mysql_pymysql_engine] ______________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_roundtrip_chunksize(conn, request, test_frame1): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2368s ) 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_frame_roundtrip", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1740: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _______________ test_api_roundtrip_chunksize[mysql_pymysql_conn] _______________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_roundtrip_chunksize(conn, request, test_frame1): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1739: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ___________ test_api_roundtrip_chunksize[postgresql_psycopg2_engine] ___________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_roundtrip_chunksize(conn, request, test_frame1): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2368s ) 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_frame_roundtrip", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1740: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ____________ test_api_roundtrip_chunksize[postgresql_psycopg2_conn] ____________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_roundtrip_chunksize(conn, request, test_frame1): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1739: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _______________ test_api_execute_sql[mysql_pymysql_engine_iris] ________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_engine_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_api_execute_sql(conn, request): 2368s # drop_sql = "DROP TABLE IF EXISTS test" # should already be done 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1758: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2368s create_and_load_iris(mysql_pymysql_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ________________ test_api_execute_sql[mysql_pymysql_conn_iris] _________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_api_execute_sql(conn, request): 2368s # drop_sql = "DROP TABLE IF EXISTS test" # should already be done 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1758: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2368s create_and_load_iris(mysql_pymysql_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ____________ test_api_execute_sql[postgresql_psycopg2_engine_iris] _____________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_engine_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_api_execute_sql(conn, request): 2368s # drop_sql = "DROP TABLE IF EXISTS test" # should already be done 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1758: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2368s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _____________ test_api_execute_sql[postgresql_psycopg2_conn_iris] ______________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn_iris' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_iris) 2368s def test_api_execute_sql(conn, request): 2368s # drop_sql = "DROP TABLE IF EXISTS test" # should already be done 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1758: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2368s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2368s with conn.begin() as con: 2368s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2368s return next(self.gen) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2368s with self.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ______________ test_api_date_parsing[mysql_pymysql_engine_types] _______________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_engine_types' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s def test_api_date_parsing(conn, request): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1769: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _______________ test_api_date_parsing[mysql_pymysql_conn_types] ________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn_types' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s def test_api_date_parsing(conn, request): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1769: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ___________ test_api_date_parsing[postgresql_psycopg2_engine_types] ____________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_engine_types' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s def test_api_date_parsing(conn, request): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1769: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ____________ test_api_date_parsing[postgresql_psycopg2_conn_types] _____________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn_types' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s def test_api_date_parsing(conn, request): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1769: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_engine_types] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_engine_types' 2368s request = > 2368s read_sql = , text = 'SELECT * FROM types' 2368s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_conn_types] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn_types' 2368s request = > 2368s read_sql = , text = 'SELECT * FROM types' 2368s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_engine_types] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_engine_types' 2368s request = > 2368s read_sql = , text = 'SELECT * FROM types' 2368s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_conn_types] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn_types' 2368s request = > 2368s read_sql = , text = 'SELECT * FROM types' 2368s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_engine_types] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_engine_types' 2368s request = > 2368s read_sql = , text = 'SELECT * FROM types' 2368s mode = ('sqlalchemy', 'fallback'), error = 'raise' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_conn_types] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn_types' 2368s request = > 2368s read_sql = , text = 'SELECT * FROM types' 2368s mode = ('sqlalchemy', 'fallback'), error = 'raise' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_engine_types] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_engine_types' 2368s request = > 2368s read_sql = , text = 'SELECT * FROM types' 2368s mode = ('sqlalchemy', 'fallback'), error = 'raise' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_conn_types] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn_types' 2368s request = > 2368s read_sql = , text = 'SELECT * FROM types' 2368s mode = ('sqlalchemy', 'fallback'), error = 'raise' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_engine_types] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_engine_types' 2368s request = > 2368s read_sql = , text = 'SELECT * FROM types' 2368s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_conn_types] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn_types' 2368s request = > 2368s read_sql = , text = 'SELECT * FROM types' 2368s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_engine_types] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_engine_types' 2368s request = > 2368s read_sql = , text = 'SELECT * FROM types' 2368s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_conn_types] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn_types' 2368s request = > 2368s read_sql = , text = 'SELECT * FROM types' 2368s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_engine_types] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_engine_types' 2368s request = > 2368s read_sql = , text = 'types' 2368s mode = 'sqlalchemy', error = 'ignore' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_conn_types] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn_types' 2368s request = > 2368s read_sql = , text = 'types' 2368s mode = 'sqlalchemy', error = 'ignore' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_engine_types' 2368s request = > 2368s read_sql = , text = 'types' 2368s mode = 'sqlalchemy', error = 'ignore' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn_types' 2368s request = > 2368s read_sql = , text = 'types' 2368s mode = 'sqlalchemy', error = 'ignore' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_engine_types] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_engine_types' 2368s request = > 2368s read_sql = , text = 'types' 2368s mode = 'sqlalchemy', error = 'raise' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_conn_types] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn_types' 2368s request = > 2368s read_sql = , text = 'types' 2368s mode = 'sqlalchemy', error = 'raise' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_engine_types' 2368s request = > 2368s read_sql = , text = 'types' 2368s mode = 'sqlalchemy', error = 'raise' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn_types' 2368s request = > 2368s read_sql = , text = 'types' 2368s mode = 'sqlalchemy', error = 'raise' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_engine_types] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_engine_types' 2368s request = > 2368s read_sql = , text = 'types' 2368s mode = 'sqlalchemy', error = 'coerce' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_conn_types] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn_types' 2368s request = > 2368s read_sql = , text = 'types' 2368s mode = 'sqlalchemy', error = 'coerce' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_engine_types' 2368s request = > 2368s read_sql = , text = 'types' 2368s mode = 'sqlalchemy', error = 'coerce' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn_types' 2368s request = > 2368s read_sql = , text = 'types' 2368s mode = 'sqlalchemy', error = 'coerce' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_engine_types] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_engine_types' 2368s request = > 2368s read_sql = 2368s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 2368s error = 'ignore' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_conn_types] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn_types' 2368s request = > 2368s read_sql = 2368s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 2368s error = 'ignore' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_engine_types] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_engine_types' 2368s request = > 2368s read_sql = 2368s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 2368s error = 'ignore' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_conn_types] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn_types' 2368s request = > 2368s read_sql = 2368s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 2368s error = 'ignore' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_engine_types] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_engine_types' 2368s request = > 2368s read_sql = 2368s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback'), error = 'raise' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_conn_types] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn_types' 2368s request = > 2368s read_sql = 2368s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback'), error = 'raise' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_engine_types] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_engine_types' 2368s request = > 2368s read_sql = 2368s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback'), error = 'raise' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_conn_types] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn_types' 2368s request = > 2368s read_sql = 2368s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback'), error = 'raise' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_engine_types] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_engine_types' 2368s request = > 2368s read_sql = 2368s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 2368s error = 'coerce' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_conn_types] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn_types' 2368s request = > 2368s read_sql = 2368s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 2368s error = 'coerce' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_engine_types] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_engine_types' 2368s request = > 2368s read_sql = 2368s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 2368s error = 'coerce' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_conn_types] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn_types' 2368s request = > 2368s read_sql = 2368s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 2368s error = 'coerce' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_engine_types] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_engine_types' 2368s request = > 2368s read_sql = , text = 'types' 2368s mode = 'sqlalchemy', error = 'ignore' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_conn_types] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn_types' 2368s request = > 2368s read_sql = , text = 'types' 2368s mode = 'sqlalchemy', error = 'ignore' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_engine_types' 2368s request = > 2368s read_sql = , text = 'types' 2368s mode = 'sqlalchemy', error = 'ignore' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn_types' 2368s request = > 2368s read_sql = , text = 'types' 2368s mode = 'sqlalchemy', error = 'ignore' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_engine_types] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_engine_types' 2368s request = > 2368s read_sql = , text = 'types' 2368s mode = 'sqlalchemy', error = 'raise' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_conn_types] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn_types' 2368s request = > 2368s read_sql = , text = 'types' 2368s mode = 'sqlalchemy', error = 'raise' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_engine_types' 2368s request = > 2368s read_sql = , text = 'types' 2368s mode = 'sqlalchemy', error = 'raise' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn_types' 2368s request = > 2368s read_sql = , text = 'types' 2368s mode = 'sqlalchemy', error = 'raise' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_engine_types] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_engine_types' 2368s request = > 2368s read_sql = , text = 'types' 2368s mode = 'sqlalchemy', error = 'coerce' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_conn_types] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn_types' 2368s request = > 2368s read_sql = , text = 'types' 2368s mode = 'sqlalchemy', error = 'coerce' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_engine_types' 2368s request = > 2368s read_sql = , text = 'types' 2368s mode = 'sqlalchemy', error = 'coerce' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn_types' 2368s request = > 2368s read_sql = , text = 'types' 2368s mode = 'sqlalchemy', error = 'coerce' 2368s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 2368s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 2368s 1 first 2000-01-04 00:00:00 ... NaN NaN 2368s 2368s [2 rows x 9 columns] 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 2368s @pytest.mark.parametrize( 2368s "read_sql, text, mode", 2368s [ 2368s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 2368s (sql.read_sql, "types", ("sqlalchemy")), 2368s ( 2368s sql.read_sql_query, 2368s "SELECT * FROM types", 2368s ("sqlalchemy", "fallback"), 2368s ), 2368s (sql.read_sql_table, "types", ("sqlalchemy")), 2368s ], 2368s ) 2368s def test_api_custom_dateparsing_error( 2368s conn, request, read_sql, text, mode, error, types_data_frame 2368s ): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _____________ test_api_date_and_index[mysql_pymysql_engine_types] ______________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_engine_types' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s def test_api_date_and_index(conn, request): 2368s # Test case where same column appears in parse_date and index_col 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1880: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ______________ test_api_date_and_index[mysql_pymysql_conn_types] _______________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn_types' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s def test_api_date_and_index(conn, request): 2368s # Test case where same column appears in parse_date and index_col 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1880: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2368s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s __________ test_api_date_and_index[postgresql_psycopg2_engine_types] ___________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_engine_types' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s def test_api_date_and_index(conn, request): 2368s # Test case where same column appears in parse_date and index_col 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1880: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ___________ test_api_date_and_index[postgresql_psycopg2_conn_types] ____________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn_types' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable_types) 2368s def test_api_date_and_index(conn, request): 2368s # Test case where same column appears in parse_date and index_col 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1880: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2368s fixturedef = request._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2368s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2368s with conn.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ___________________ test_api_timedelta[mysql_pymysql_engine] ___________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_timedelta(conn, request): 2368s # see #6921 2368s conn_name = conn 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_timedelta", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1897: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ____________________ test_api_timedelta[mysql_pymysql_conn] ____________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_timedelta(conn, request): 2368s # see #6921 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1896: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ________________ test_api_timedelta[postgresql_psycopg2_engine] ________________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_timedelta(conn, request): 2368s # see #6921 2368s conn_name = conn 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_timedelta", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1897: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _________________ test_api_timedelta[postgresql_psycopg2_conn] _________________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_timedelta(conn, request): 2368s # see #6921 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1896: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ________________ test_api_complex_raises[mysql_pymysql_engine] _________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_complex_raises(conn, request): 2368s conn_name = conn 2368s conn = request.getfixturevalue(conn) 2368s df = DataFrame({"a": [1 + 1j, 2j]}) 2368s 2368s if "adbc" in conn_name: 2368s msg = "datatypes not supported" 2368s else: 2368s msg = "Complex datatypes not supported" 2368s with pytest.raises(ValueError, match=msg): 2368s > assert df.to_sql("test_complex", con=conn) is None 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1950: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2368s return func(*args, **kwargs) 2368s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2368s return sql.to_sql( 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2368s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _________________ test_api_complex_raises[mysql_pymysql_conn] __________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_complex_raises(conn, request): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1942: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _____________ test_api_complex_raises[postgresql_psycopg2_engine] ______________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_complex_raises(conn, request): 2368s conn_name = conn 2368s conn = request.getfixturevalue(conn) 2368s df = DataFrame({"a": [1 + 1j, 2j]}) 2368s 2368s if "adbc" in conn_name: 2368s msg = "datatypes not supported" 2368s else: 2368s msg = "Complex datatypes not supported" 2368s with pytest.raises(ValueError, match=msg): 2368s > assert df.to_sql("test_complex", con=conn) is None 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1950: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2368s return func(*args, **kwargs) 2368s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2368s return sql.to_sql( 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2368s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ______________ test_api_complex_raises[postgresql_psycopg2_conn] _______________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_complex_raises(conn, request): 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1942: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ______ test_api_to_sql_index_label[None-None-index-mysql_pymysql_engine] _______ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s request = > 2368s index_name = None, index_label = None, expected = 'index' 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "index_name,index_label,expected", 2368s [ 2368s # no index name, defaults to 'index' 2368s (None, None, "index"), 2368s # specifying index_label 2368s (None, "other_label", "other_label"), 2368s # using the index name 2368s ("index_name", None, "index_name"), 2368s # has index name, but specifying index_label 2368s ("index_name", "other_label", "other_label"), 2368s # index name is integer 2368s (0, None, "0"), 2368s # index name is None but index label is integer 2368s (None, 0, "0"), 2368s ], 2368s ) 2368s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2368s ) 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_index_label", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _______ test_api_to_sql_index_label[None-None-index-mysql_pymysql_conn] ________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s request = > 2368s index_name = None, index_label = None, expected = 'index' 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "index_name,index_label,expected", 2368s [ 2368s # no index name, defaults to 'index' 2368s (None, None, "index"), 2368s # specifying index_label 2368s (None, "other_label", "other_label"), 2368s # using the index name 2368s ("index_name", None, "index_name"), 2368s # has index name, but specifying index_label 2368s ("index_name", "other_label", "other_label"), 2368s # index name is integer 2368s (0, None, "0"), 2368s # index name is None but index label is integer 2368s (None, 0, "0"), 2368s ], 2368s ) 2368s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ___ test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_engine] ____ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s index_name = None, index_label = None, expected = 'index' 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "index_name,index_label,expected", 2368s [ 2368s # no index name, defaults to 'index' 2368s (None, None, "index"), 2368s # specifying index_label 2368s (None, "other_label", "other_label"), 2368s # using the index name 2368s ("index_name", None, "index_name"), 2368s # has index name, but specifying index_label 2368s ("index_name", "other_label", "other_label"), 2368s # index name is integer 2368s (0, None, "0"), 2368s # index name is None but index label is integer 2368s (None, 0, "0"), 2368s ], 2368s ) 2368s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2368s ) 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_index_label", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ____ test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_conn] _____ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s request = > 2368s index_name = None, index_label = None, expected = 'index' 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "index_name,index_label,expected", 2368s [ 2368s # no index name, defaults to 'index' 2368s (None, None, "index"), 2368s # specifying index_label 2368s (None, "other_label", "other_label"), 2368s # using the index name 2368s ("index_name", None, "index_name"), 2368s # has index name, but specifying index_label 2368s ("index_name", "other_label", "other_label"), 2368s # index name is integer 2368s (0, None, "0"), 2368s # index name is None but index label is integer 2368s (None, 0, "0"), 2368s ], 2368s ) 2368s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_engine] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s request = > 2368s index_name = None, index_label = 'other_label', expected = 'other_label' 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "index_name,index_label,expected", 2368s [ 2368s # no index name, defaults to 'index' 2368s (None, None, "index"), 2368s # specifying index_label 2368s (None, "other_label", "other_label"), 2368s # using the index name 2368s ("index_name", None, "index_name"), 2368s # has index name, but specifying index_label 2368s ("index_name", "other_label", "other_label"), 2368s # index name is integer 2368s (0, None, "0"), 2368s # index name is None but index label is integer 2368s (None, 0, "0"), 2368s ], 2368s ) 2368s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2368s ) 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_index_label", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_conn] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s request = > 2368s index_name = None, index_label = 'other_label', expected = 'other_label' 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "index_name,index_label,expected", 2368s [ 2368s # no index name, defaults to 'index' 2368s (None, None, "index"), 2368s # specifying index_label 2368s (None, "other_label", "other_label"), 2368s # using the index name 2368s ("index_name", None, "index_name"), 2368s # has index name, but specifying index_label 2368s ("index_name", "other_label", "other_label"), 2368s # index name is integer 2368s (0, None, "0"), 2368s # index name is None but index label is integer 2368s (None, 0, "0"), 2368s ], 2368s ) 2368s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_engine] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s index_name = None, index_label = 'other_label', expected = 'other_label' 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "index_name,index_label,expected", 2368s [ 2368s # no index name, defaults to 'index' 2368s (None, None, "index"), 2368s # specifying index_label 2368s (None, "other_label", "other_label"), 2368s # using the index name 2368s ("index_name", None, "index_name"), 2368s # has index name, but specifying index_label 2368s ("index_name", "other_label", "other_label"), 2368s # index name is integer 2368s (0, None, "0"), 2368s # index name is None but index label is integer 2368s (None, 0, "0"), 2368s ], 2368s ) 2368s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2368s ) 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_index_label", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_conn] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s request = > 2368s index_name = None, index_label = 'other_label', expected = 'other_label' 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "index_name,index_label,expected", 2368s [ 2368s # no index name, defaults to 'index' 2368s (None, None, "index"), 2368s # specifying index_label 2368s (None, "other_label", "other_label"), 2368s # using the index name 2368s ("index_name", None, "index_name"), 2368s # has index name, but specifying index_label 2368s ("index_name", "other_label", "other_label"), 2368s # index name is integer 2368s (0, None, "0"), 2368s # index name is None but index label is integer 2368s (None, 0, "0"), 2368s ], 2368s ) 2368s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_engine] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s request = > 2368s index_name = 'index_name', index_label = None, expected = 'index_name' 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "index_name,index_label,expected", 2368s [ 2368s # no index name, defaults to 'index' 2368s (None, None, "index"), 2368s # specifying index_label 2368s (None, "other_label", "other_label"), 2368s # using the index name 2368s ("index_name", None, "index_name"), 2368s # has index name, but specifying index_label 2368s ("index_name", "other_label", "other_label"), 2368s # index name is integer 2368s (0, None, "0"), 2368s # index name is None but index label is integer 2368s (None, 0, "0"), 2368s ], 2368s ) 2368s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2368s ) 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_index_label", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s __ test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_conn] __ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s request = > 2368s index_name = 'index_name', index_label = None, expected = 'index_name' 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "index_name,index_label,expected", 2368s [ 2368s # no index name, defaults to 'index' 2368s (None, None, "index"), 2368s # specifying index_label 2368s (None, "other_label", "other_label"), 2368s # using the index name 2368s ("index_name", None, "index_name"), 2368s # has index name, but specifying index_label 2368s ("index_name", "other_label", "other_label"), 2368s # index name is integer 2368s (0, None, "0"), 2368s # index name is None but index label is integer 2368s (None, 0, "0"), 2368s ], 2368s ) 2368s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_engine] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s index_name = 'index_name', index_label = None, expected = 'index_name' 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "index_name,index_label,expected", 2368s [ 2368s # no index name, defaults to 'index' 2368s (None, None, "index"), 2368s # specifying index_label 2368s (None, "other_label", "other_label"), 2368s # using the index name 2368s ("index_name", None, "index_name"), 2368s # has index name, but specifying index_label 2368s ("index_name", "other_label", "other_label"), 2368s # index name is integer 2368s (0, None, "0"), 2368s # index name is None but index label is integer 2368s (None, 0, "0"), 2368s ], 2368s ) 2368s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2368s ) 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_index_label", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_conn] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s request = > 2368s index_name = 'index_name', index_label = None, expected = 'index_name' 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "index_name,index_label,expected", 2368s [ 2368s # no index name, defaults to 'index' 2368s (None, None, "index"), 2368s # specifying index_label 2368s (None, "other_label", "other_label"), 2368s # using the index name 2368s ("index_name", None, "index_name"), 2368s # has index name, but specifying index_label 2368s ("index_name", "other_label", "other_label"), 2368s # index name is integer 2368s (0, None, "0"), 2368s # index name is None but index label is integer 2368s (None, 0, "0"), 2368s ], 2368s ) 2368s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_engine] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s request = > 2368s index_name = 'index_name', index_label = 'other_label', expected = 'other_label' 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "index_name,index_label,expected", 2368s [ 2368s # no index name, defaults to 'index' 2368s (None, None, "index"), 2368s # specifying index_label 2368s (None, "other_label", "other_label"), 2368s # using the index name 2368s ("index_name", None, "index_name"), 2368s # has index name, but specifying index_label 2368s ("index_name", "other_label", "other_label"), 2368s # index name is integer 2368s (0, None, "0"), 2368s # index name is None but index label is integer 2368s (None, 0, "0"), 2368s ], 2368s ) 2368s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2368s ) 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_index_label", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_conn] _ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s request = > 2368s index_name = 'index_name', index_label = 'other_label', expected = 'other_label' 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "index_name,index_label,expected", 2368s [ 2368s # no index name, defaults to 'index' 2368s (None, None, "index"), 2368s # specifying index_label 2368s (None, "other_label", "other_label"), 2368s # using the index name 2368s ("index_name", None, "index_name"), 2368s # has index name, but specifying index_label 2368s ("index_name", "other_label", "other_label"), 2368s # index name is integer 2368s (0, None, "0"), 2368s # index name is None but index label is integer 2368s (None, 0, "0"), 2368s ], 2368s ) 2368s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _ test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_engine] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s index_name = 'index_name', index_label = 'other_label', expected = 'other_label' 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "index_name,index_label,expected", 2368s [ 2368s # no index name, defaults to 'index' 2368s (None, None, "index"), 2368s # specifying index_label 2368s (None, "other_label", "other_label"), 2368s # using the index name 2368s ("index_name", None, "index_name"), 2368s # has index name, but specifying index_label 2368s ("index_name", "other_label", "other_label"), 2368s # index name is integer 2368s (0, None, "0"), 2368s # index name is None but index label is integer 2368s (None, 0, "0"), 2368s ], 2368s ) 2368s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2368s ) 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_index_label", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _ test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_conn] _ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s request = > 2368s index_name = 'index_name', index_label = 'other_label', expected = 'other_label' 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "index_name,index_label,expected", 2368s [ 2368s # no index name, defaults to 'index' 2368s (None, None, "index"), 2368s # specifying index_label 2368s (None, "other_label", "other_label"), 2368s # using the index name 2368s ("index_name", None, "index_name"), 2368s # has index name, but specifying index_label 2368s ("index_name", "other_label", "other_label"), 2368s # index name is integer 2368s (0, None, "0"), 2368s # index name is None but index label is integer 2368s (None, 0, "0"), 2368s ], 2368s ) 2368s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s __________ test_api_to_sql_index_label[0-None-0-mysql_pymysql_engine] __________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s request = > 2368s index_name = 0, index_label = None, expected = '0' 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "index_name,index_label,expected", 2368s [ 2368s # no index name, defaults to 'index' 2368s (None, None, "index"), 2368s # specifying index_label 2368s (None, "other_label", "other_label"), 2368s # using the index name 2368s ("index_name", None, "index_name"), 2368s # has index name, but specifying index_label 2368s ("index_name", "other_label", "other_label"), 2368s # index name is integer 2368s (0, None, "0"), 2368s # index name is None but index label is integer 2368s (None, 0, "0"), 2368s ], 2368s ) 2368s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2368s ) 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_index_label", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ___________ test_api_to_sql_index_label[0-None-0-mysql_pymysql_conn] ___________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s request = > 2368s index_name = 0, index_label = None, expected = '0' 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "index_name,index_label,expected", 2368s [ 2368s # no index name, defaults to 'index' 2368s (None, None, "index"), 2368s # specifying index_label 2368s (None, "other_label", "other_label"), 2368s # using the index name 2368s ("index_name", None, "index_name"), 2368s # has index name, but specifying index_label 2368s ("index_name", "other_label", "other_label"), 2368s # index name is integer 2368s (0, None, "0"), 2368s # index name is None but index label is integer 2368s (None, 0, "0"), 2368s ], 2368s ) 2368s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _______ test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_engine] _______ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s index_name = 0, index_label = None, expected = '0' 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "index_name,index_label,expected", 2368s [ 2368s # no index name, defaults to 'index' 2368s (None, None, "index"), 2368s # specifying index_label 2368s (None, "other_label", "other_label"), 2368s # using the index name 2368s ("index_name", None, "index_name"), 2368s # has index name, but specifying index_label 2368s ("index_name", "other_label", "other_label"), 2368s # index name is integer 2368s (0, None, "0"), 2368s # index name is None but index label is integer 2368s (None, 0, "0"), 2368s ], 2368s ) 2368s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2368s ) 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_index_label", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ________ test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_conn] ________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s request = > 2368s index_name = 0, index_label = None, expected = '0' 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "index_name,index_label,expected", 2368s [ 2368s # no index name, defaults to 'index' 2368s (None, None, "index"), 2368s # specifying index_label 2368s (None, "other_label", "other_label"), 2368s # using the index name 2368s ("index_name", None, "index_name"), 2368s # has index name, but specifying index_label 2368s ("index_name", "other_label", "other_label"), 2368s # index name is integer 2368s (0, None, "0"), 2368s # index name is None but index label is integer 2368s (None, 0, "0"), 2368s ], 2368s ) 2368s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s __________ test_api_to_sql_index_label[None-0-0-mysql_pymysql_engine] __________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s request = > 2368s index_name = None, index_label = 0, expected = '0' 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "index_name,index_label,expected", 2368s [ 2368s # no index name, defaults to 'index' 2368s (None, None, "index"), 2368s # specifying index_label 2368s (None, "other_label", "other_label"), 2368s # using the index name 2368s ("index_name", None, "index_name"), 2368s # has index name, but specifying index_label 2368s ("index_name", "other_label", "other_label"), 2368s # index name is integer 2368s (0, None, "0"), 2368s # index name is None but index label is integer 2368s (None, 0, "0"), 2368s ], 2368s ) 2368s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2368s ) 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_index_label", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ___________ test_api_to_sql_index_label[None-0-0-mysql_pymysql_conn] ___________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s request = > 2368s index_name = None, index_label = 0, expected = '0' 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "index_name,index_label,expected", 2368s [ 2368s # no index name, defaults to 'index' 2368s (None, None, "index"), 2368s # specifying index_label 2368s (None, "other_label", "other_label"), 2368s # using the index name 2368s ("index_name", None, "index_name"), 2368s # has index name, but specifying index_label 2368s ("index_name", "other_label", "other_label"), 2368s # index name is integer 2368s (0, None, "0"), 2368s # index name is None but index label is integer 2368s (None, 0, "0"), 2368s ], 2368s ) 2368s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _______ test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_engine] _______ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s index_name = None, index_label = 0, expected = '0' 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "index_name,index_label,expected", 2368s [ 2368s # no index name, defaults to 'index' 2368s (None, None, "index"), 2368s # specifying index_label 2368s (None, "other_label", "other_label"), 2368s # using the index name 2368s ("index_name", None, "index_name"), 2368s # has index name, but specifying index_label 2368s ("index_name", "other_label", "other_label"), 2368s # index name is integer 2368s (0, None, "0"), 2368s # index name is None but index label is integer 2368s (None, 0, "0"), 2368s ], 2368s ) 2368s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2368s ) 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_index_label", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ________ test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_conn] ________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s request = > 2368s index_name = None, index_label = 0, expected = '0' 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "index_name,index_label,expected", 2368s [ 2368s # no index name, defaults to 'index' 2368s (None, None, "index"), 2368s # specifying index_label 2368s (None, "other_label", "other_label"), 2368s # using the index name 2368s ("index_name", None, "index_name"), 2368s # has index name, but specifying index_label 2368s ("index_name", "other_label", "other_label"), 2368s # index name is integer 2368s (0, None, "0"), 2368s # index name is None but index label is integer 2368s (None, 0, "0"), 2368s ], 2368s ) 2368s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ______ test_api_to_sql_index_label_multiindex[postgresql_psycopg2_engine] ______ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_to_sql_index_label_multiindex(conn, request): 2368s conn_name = conn 2368s if "mysql" in conn_name: 2368s request.applymarker( 2368s pytest.mark.xfail( 2368s reason="MySQL can fail using TEXT without length as key", strict=False 2368s ) 2368s ) 2368s elif "adbc" in conn_name: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2368s ) 2368s 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_index_label", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2004: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _______ test_api_to_sql_index_label_multiindex[postgresql_psycopg2_conn] _______ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_to_sql_index_label_multiindex(conn, request): 2368s conn_name = conn 2368s if "mysql" in conn_name: 2368s request.applymarker( 2368s pytest.mark.xfail( 2368s reason="MySQL can fail using TEXT without length as key", strict=False 2368s ) 2368s ) 2368s elif "adbc" in conn_name: 2368s request.node.add_marker( 2368s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 2368s ) 2368s 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2003: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _____________ test_api_multiindex_roundtrip[mysql_pymysql_engine] ______________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_multiindex_roundtrip(conn, request): 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_multiindex_roundtrip", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2066: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ______________ test_api_multiindex_roundtrip[mysql_pymysql_conn] _______________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_multiindex_roundtrip(conn, request): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2065: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s __________ test_api_multiindex_roundtrip[postgresql_psycopg2_engine] ___________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_multiindex_roundtrip(conn, request): 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_multiindex_roundtrip", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2066: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ___________ test_api_multiindex_roundtrip[postgresql_psycopg2_conn] ____________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_multiindex_roundtrip(conn, request): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2065: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ______________ test_api_dtype_argument[None-mysql_pymysql_engine] ______________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s request = > 2368s dtype = None 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "dtype", 2368s [ 2368s None, 2368s int, 2368s float, 2368s {"A": int, "B": float}, 2368s ], 2368s ) 2368s def test_api_dtype_argument(conn, request, dtype): 2368s # GH10285 Add dtype argument to read_sql_query 2368s conn_name = conn 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_dtype_argument", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _______________ test_api_dtype_argument[None-mysql_pymysql_conn] _______________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s request = > 2368s dtype = None 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "dtype", 2368s [ 2368s None, 2368s int, 2368s float, 2368s {"A": int, "B": float}, 2368s ], 2368s ) 2368s def test_api_dtype_argument(conn, request, dtype): 2368s # GH10285 Add dtype argument to read_sql_query 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ___________ test_api_dtype_argument[None-postgresql_psycopg2_engine] ___________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s dtype = None 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "dtype", 2368s [ 2368s None, 2368s int, 2368s float, 2368s {"A": int, "B": float}, 2368s ], 2368s ) 2368s def test_api_dtype_argument(conn, request, dtype): 2368s # GH10285 Add dtype argument to read_sql_query 2368s conn_name = conn 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_dtype_argument", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ____________ test_api_dtype_argument[None-postgresql_psycopg2_conn] ____________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s request = > 2368s dtype = None 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "dtype", 2368s [ 2368s None, 2368s int, 2368s float, 2368s {"A": int, "B": float}, 2368s ], 2368s ) 2368s def test_api_dtype_argument(conn, request, dtype): 2368s # GH10285 Add dtype argument to read_sql_query 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ______________ test_api_dtype_argument[int-mysql_pymysql_engine] _______________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s request = > 2368s dtype = 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "dtype", 2368s [ 2368s None, 2368s int, 2368s float, 2368s {"A": int, "B": float}, 2368s ], 2368s ) 2368s def test_api_dtype_argument(conn, request, dtype): 2368s # GH10285 Add dtype argument to read_sql_query 2368s conn_name = conn 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_dtype_argument", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _______________ test_api_dtype_argument[int-mysql_pymysql_conn] ________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s request = > 2368s dtype = 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "dtype", 2368s [ 2368s None, 2368s int, 2368s float, 2368s {"A": int, "B": float}, 2368s ], 2368s ) 2368s def test_api_dtype_argument(conn, request, dtype): 2368s # GH10285 Add dtype argument to read_sql_query 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ___________ test_api_dtype_argument[int-postgresql_psycopg2_engine] ____________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s dtype = 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "dtype", 2368s [ 2368s None, 2368s int, 2368s float, 2368s {"A": int, "B": float}, 2368s ], 2368s ) 2368s def test_api_dtype_argument(conn, request, dtype): 2368s # GH10285 Add dtype argument to read_sql_query 2368s conn_name = conn 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_dtype_argument", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ____________ test_api_dtype_argument[int-postgresql_psycopg2_conn] _____________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s request = > 2368s dtype = 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "dtype", 2368s [ 2368s None, 2368s int, 2368s float, 2368s {"A": int, "B": float}, 2368s ], 2368s ) 2368s def test_api_dtype_argument(conn, request, dtype): 2368s # GH10285 Add dtype argument to read_sql_query 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _____________ test_api_dtype_argument[float-mysql_pymysql_engine] ______________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s request = > 2368s dtype = 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "dtype", 2368s [ 2368s None, 2368s int, 2368s float, 2368s {"A": int, "B": float}, 2368s ], 2368s ) 2368s def test_api_dtype_argument(conn, request, dtype): 2368s # GH10285 Add dtype argument to read_sql_query 2368s conn_name = conn 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_dtype_argument", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ______________ test_api_dtype_argument[float-mysql_pymysql_conn] _______________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s request = > 2368s dtype = 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "dtype", 2368s [ 2368s None, 2368s int, 2368s float, 2368s {"A": int, "B": float}, 2368s ], 2368s ) 2368s def test_api_dtype_argument(conn, request, dtype): 2368s # GH10285 Add dtype argument to read_sql_query 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s __________ test_api_dtype_argument[float-postgresql_psycopg2_engine] ___________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s dtype = 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "dtype", 2368s [ 2368s None, 2368s int, 2368s float, 2368s {"A": int, "B": float}, 2368s ], 2368s ) 2368s def test_api_dtype_argument(conn, request, dtype): 2368s # GH10285 Add dtype argument to read_sql_query 2368s conn_name = conn 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_dtype_argument", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ___________ test_api_dtype_argument[float-postgresql_psycopg2_conn] ____________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s request = > 2368s dtype = 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "dtype", 2368s [ 2368s None, 2368s int, 2368s float, 2368s {"A": int, "B": float}, 2368s ], 2368s ) 2368s def test_api_dtype_argument(conn, request, dtype): 2368s # GH10285 Add dtype argument to read_sql_query 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _____________ test_api_dtype_argument[dtype3-mysql_pymysql_engine] _____________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s request = > 2368s dtype = {'A': , 'B': } 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "dtype", 2368s [ 2368s None, 2368s int, 2368s float, 2368s {"A": int, "B": float}, 2368s ], 2368s ) 2368s def test_api_dtype_argument(conn, request, dtype): 2368s # GH10285 Add dtype argument to read_sql_query 2368s conn_name = conn 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_dtype_argument", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ______________ test_api_dtype_argument[dtype3-mysql_pymysql_conn] ______________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s request = > 2368s dtype = {'A': , 'B': } 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "dtype", 2368s [ 2368s None, 2368s int, 2368s float, 2368s {"A": int, "B": float}, 2368s ], 2368s ) 2368s def test_api_dtype_argument(conn, request, dtype): 2368s # GH10285 Add dtype argument to read_sql_query 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s __________ test_api_dtype_argument[dtype3-postgresql_psycopg2_engine] __________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s dtype = {'A': , 'B': } 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "dtype", 2368s [ 2368s None, 2368s int, 2368s float, 2368s {"A": int, "B": float}, 2368s ], 2368s ) 2368s def test_api_dtype_argument(conn, request, dtype): 2368s # GH10285 Add dtype argument to read_sql_query 2368s conn_name = conn 2368s conn = request.getfixturevalue(conn) 2368s > if sql.has_table("test_dtype_argument", conn): 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2368s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ___________ test_api_dtype_argument[dtype3-postgresql_psycopg2_conn] ___________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s request = > 2368s dtype = {'A': , 'B': } 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s @pytest.mark.parametrize( 2368s "dtype", 2368s [ 2368s None, 2368s int, 2368s float, 2368s {"A": int, "B": float}, 2368s ], 2368s ) 2368s def test_api_dtype_argument(conn, request, dtype): 2368s # GH10285 Add dtype argument to read_sql_query 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _______________ test_api_integer_col_names[mysql_pymysql_engine] _______________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_integer_col_names(conn, request): 2368s conn = request.getfixturevalue(conn) 2368s df = DataFrame([[1, 2], [3, 4]], columns=[0, 1]) 2368s > sql.to_sql(df, "test_frame_integer_col_names", conn, if_exists="replace") 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2119: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2368s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ________________ test_api_integer_col_names[mysql_pymysql_conn] ________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_integer_col_names(conn, request): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2117: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ____________ test_api_integer_col_names[postgresql_psycopg2_engine] ____________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_integer_col_names(conn, request): 2368s conn = request.getfixturevalue(conn) 2368s df = DataFrame([[1, 2], [3, 4]], columns=[0, 1]) 2368s > sql.to_sql(df, "test_frame_integer_col_names", conn, if_exists="replace") 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2119: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2368s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _____________ test_api_integer_col_names[postgresql_psycopg2_conn] _____________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_integer_col_names(conn, request): 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2117: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s __________________ test_api_get_schema[mysql_pymysql_engine] ___________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_get_schema(conn, request, test_frame1): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'get_schema' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s conn = request.getfixturevalue(conn) 2368s > create_sql = sql.get_schema(test_frame1, "test", con=conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2132: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2368s with pandasSQL_builder(con=con) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ___________________ test_api_get_schema[mysql_pymysql_conn] ____________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_get_schema(conn, request, test_frame1): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'get_schema' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2131: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _______________ test_api_get_schema[postgresql_psycopg2_engine] ________________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_get_schema(conn, request, test_frame1): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'get_schema' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s conn = request.getfixturevalue(conn) 2368s > create_sql = sql.get_schema(test_frame1, "test", con=conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2132: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2368s with pandasSQL_builder(con=con) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ________________ test_api_get_schema[postgresql_psycopg2_conn] _________________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_get_schema(conn, request, test_frame1): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'get_schema' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2131: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s ____________ test_api_get_schema_with_schema[mysql_pymysql_engine] _____________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_get_schema_with_schema(conn, request, test_frame1): 2368s # GH28486 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'get_schema' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s conn = request.getfixturevalue(conn) 2368s > create_sql = sql.get_schema(test_frame1, "test", con=conn, schema="pypi") 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2147: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2368s with pandasSQL_builder(con=con) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _____________ test_api_get_schema_with_schema[mysql_pymysql_conn] ______________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_get_schema_with_schema(conn, request, test_frame1): 2368s # GH28486 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'get_schema' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s _________ test_api_get_schema_with_schema[postgresql_psycopg2_engine] __________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_get_schema_with_schema(conn, request, test_frame1): 2368s # GH28486 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'get_schema' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s conn = request.getfixturevalue(conn) 2368s > create_sql = sql.get_schema(test_frame1, "test", con=conn, schema="pypi") 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2147: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2368s with pandasSQL_builder(con=con) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s __________ test_api_get_schema_with_schema[postgresql_psycopg2_conn] ___________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'postgresql_psycopg2_conn' 2368s request = > 2368s test_frame1 = index A B C D 2368s 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 2368s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_get_schema_with_schema(conn, request, test_frame1): 2368s # GH28486 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'get_schema' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2368s with postgresql_psycopg2_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _______________ test_api_get_schema_dtypes[mysql_pymysql_engine] _______________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_get_schema_dtypes(conn, request): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'get_schema' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s conn_name = conn 2368s conn = request.getfixturevalue(conn) 2368s float_frame = DataFrame({"a": [1.1, 1.2], "b": [2.1, 2.2]}) 2368s 2368s if conn_name == "sqlite_buildin": 2368s dtype = "INTEGER" 2368s else: 2368s from sqlalchemy import Integer 2368s 2368s dtype = Integer 2368s > create_sql = sql.get_schema(float_frame, "test", con=conn, dtype={"b": dtype}) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2170: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2368s with pandasSQL_builder(con=con) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ________________ test_api_get_schema_dtypes[mysql_pymysql_conn] ________________ 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s > sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3.13/socket.py:864: in create_connection 2368s raise exceptions[0] 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s address = ('localhost', 3306), timeout = 10, source_address = None 2368s 2368s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2368s source_address=None, *, all_errors=False): 2368s """Connect to *address* and return the socket object. 2368s 2368s Convenience function. Connect to *address* (a 2-tuple ``(host, 2368s port)``) and return the socket object. Passing the optional 2368s *timeout* parameter will set the timeout on the socket instance 2368s before attempting to connect. If no *timeout* is supplied, the 2368s global default timeout setting returned by :func:`getdefaulttimeout` 2368s is used. If *source_address* is set it must be a tuple of (host, port) 2368s for the socket to bind as a source address before making the connection. 2368s A host of '' or port 0 tells the OS to use the default. When a connection 2368s cannot be created, raises the last error if *all_errors* is False, 2368s and an ExceptionGroup of all errors if *all_errors* is True. 2368s """ 2368s 2368s host, port = address 2368s exceptions = [] 2368s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2368s af, socktype, proto, canonname, sa = res 2368s sock = None 2368s try: 2368s sock = socket(af, socktype, proto) 2368s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2368s sock.settimeout(timeout) 2368s if source_address: 2368s sock.bind(source_address) 2368s > sock.connect(sa) 2368s E ConnectionRefusedError: [Errno 111] Connection refused 2368s 2368s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2368s 2368s During handling of the above exception, another exception occurred: 2368s 2368s self = 2368s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2368s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = 'mysql_pymysql_conn' 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_get_schema_dtypes(conn, request): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'get_schema' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s conn_name = conn 2368s > conn = request.getfixturevalue(conn) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2161: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2368s fixturedef = self._get_active_fixturedef(argname) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2368s fixturedef.execute(request=subrequest) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2368s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2368s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2368s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2368s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2368s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2368s return (yield) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2368s result = call_fixture_func(fixturefunc, request, kwargs) 2368s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2368s fixture_result = next(generator) 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2368s with mysql_pymysql_engine.connect() as conn: 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2368s self.connect() 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s self = , sock = None 2368s 2368s def connect(self, sock=None): 2368s self._closed = False 2368s try: 2368s if sock is None: 2368s if self.unix_socket: 2368s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2368s sock.settimeout(self.connect_timeout) 2368s sock.connect(self.unix_socket) 2368s self.host_info = "Localhost via UNIX socket" 2368s self._secure = True 2368s if DEBUG: 2368s print("connected using unix_socket") 2368s else: 2368s kwargs = {} 2368s if self.bind_address is not None: 2368s kwargs["source_address"] = (self.bind_address, 0) 2368s while True: 2368s try: 2368s sock = socket.create_connection( 2368s (self.host, self.port), self.connect_timeout, **kwargs 2368s ) 2368s break 2368s except OSError as e: 2368s if e.errno == errno.EINTR: 2368s continue 2368s raise 2368s self.host_info = "socket %s:%d" % (self.host, self.port) 2368s if DEBUG: 2368s print("connected using socket") 2368s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2368s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2368s sock.settimeout(None) 2368s 2368s self._sock = sock 2368s self._rfile = sock.makefile("rb") 2368s self._next_seq_id = 0 2368s 2368s self._get_server_information() 2368s self._request_authentication() 2368s 2368s # Send "SET NAMES" query on init for: 2368s # - Ensure charaset (and collation) is set to the server. 2368s # - collation_id in handshake packet may be ignored. 2368s # - If collation is not specified, we don't know what is server's 2368s # default collation for the charset. For example, default collation 2368s # of utf8mb4 is: 2368s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2368s # - MySQL 8.0: utf8mb4_0900_ai_ci 2368s # 2368s # Reference: 2368s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2368s # - https://github.com/wagtail/wagtail/issues/9477 2368s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2368s self.set_character_set(self.charset, self.collation) 2368s 2368s if self.sql_mode is not None: 2368s c = self.cursor() 2368s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2368s c.close() 2368s 2368s if self.init_command is not None: 2368s c = self.cursor() 2368s c.execute(self.init_command) 2368s c.close() 2368s 2368s if self.autocommit_mode is not None: 2368s self.autocommit(self.autocommit_mode) 2368s except BaseException as e: 2368s self._rfile = None 2368s if sock is not None: 2368s try: 2368s sock.close() 2368s except: # noqa 2368s pass 2368s 2368s if isinstance(e, (OSError, IOError)): 2368s exc = err.OperationalError( 2368s CR.CR_CONN_HOST_ERROR, 2368s f"Can't connect to MySQL server on {self.host!r} ({e})", 2368s ) 2368s # Keep original exception and traceback to investigate error. 2368s exc.original_exception = e 2368s exc.traceback = traceback.format_exc() 2368s if DEBUG: 2368s print(exc.traceback) 2368s > raise exc 2368s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2368s ____________ test_api_get_schema_dtypes[postgresql_psycopg2_engine] ____________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s 2368s The above exception was the direct cause of the following exception: 2368s 2368s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s request = > 2368s 2368s @pytest.mark.parametrize("conn", all_connectable) 2368s def test_api_get_schema_dtypes(conn, request): 2368s if "adbc" in conn: 2368s request.node.add_marker( 2368s pytest.mark.xfail( 2368s reason="'get_schema' not implemented for ADBC drivers", 2368s strict=True, 2368s ) 2368s ) 2368s conn_name = conn 2368s conn = request.getfixturevalue(conn) 2368s float_frame = DataFrame({"a": [1.1, 1.2], "b": [2.1, 2.2]}) 2368s 2368s if conn_name == "sqlite_buildin": 2368s dtype = "INTEGER" 2368s else: 2368s from sqlalchemy import Integer 2368s 2368s dtype = Integer 2368s > create_sql = sql.get_schema(float_frame, "test", con=conn, dtype={"b": dtype}) 2368s 2368s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2170: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2368s with pandasSQL_builder(con=con) as pandas_sql: 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2368s return SQLDatabase(con, schema, need_transaction) 2368s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2368s con = self.exit_stack.enter_context(con.connect()) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2368s return self._connection_cls(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2368s Connection._handle_dbapi_exception_noconnection( 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2368s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2368s self._dbapi_connection = engine.raw_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2368s argument. 2368s 2368s Using the *cursor_factory* parameter, a new default cursor factory will be 2368s used by cursor(). 2368s 2368s Using *async*=True an asynchronous connection will be created. *async_* is 2368s a valid alias (for Python versions where ``async`` is a keyword). 2368s 2368s Any other keyword parameter will be passed to the underlying client 2368s library: the list of supported parameters depends on the library version. 2368s 2368s """ 2368s kwasync = {} 2368s if 'async' in kwargs: 2368s kwasync['async'] = kwargs.pop('async') 2368s if 'async_' in kwargs: 2368s kwasync['async_'] = kwargs.pop('async_') 2368s 2368s dsn = _ext.make_dsn(dsn, **kwargs) 2368s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2368s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2368s E Is the server running on that host and accepting TCP/IP connections? 2368s E 2368s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2368s 2368s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2368s _____________ test_api_get_schema_dtypes[postgresql_psycopg2_conn] _____________ 2368s self = 2368s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2368s connection = None, _has_events = None, _allow_revalidate = True 2368s _allow_autobegin = True 2368s 2368s def __init__( 2368s self, 2368s engine: Engine, 2368s connection: Optional[PoolProxiedConnection] = None, 2368s _has_events: Optional[bool] = None, 2368s _allow_revalidate: bool = True, 2368s _allow_autobegin: bool = True, 2368s ): 2368s """Construct a new Connection.""" 2368s self.engine = engine 2368s self.dialect = dialect = engine.dialect 2368s 2368s if connection is None: 2368s try: 2368s > self._dbapi_connection = engine.raw_connection() 2368s 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2368s return self.pool.connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2368s return _ConnectionFairy._checkout(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2368s fairy = _ConnectionRecord.checkout(pool) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2368s rec = pool._do_get() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2368s return self._create_connection() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2368s return _ConnectionRecord(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2368s self.__connect() 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2368s with util.safe_reraise(): 2368s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2368s raise exc_value.with_traceback(exc_tb) 2368s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2368s self.dbapi_connection = connection = pool._invoke_creator(self) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2368s return dialect.connect(*cargs, **cparams) 2368s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2368s return self.loaded_dbapi.connect(*cargs, **cparams) 2368s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2368s 2368s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2368s connection_factory = None, cursor_factory = None 2368s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2368s kwasync = {} 2368s 2368s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2368s """ 2368s Create a new database connection. 2368s 2368s The connection parameters can be specified as a string: 2368s 2368s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2368s 2368s or using a set of keyword arguments: 2368s 2368s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2368s 2368s Or as a mix of both. The basic connection parameters are: 2368s 2368s - *dbname*: the database name 2368s - *database*: the database name (only as keyword argument) 2368s - *user*: user name used to authenticate 2368s - *password*: password used to authenticate 2368s - *host*: database host address (defaults to UNIX socket if not provided) 2368s - *port*: connection port number (defaults to 5432 if not provided) 2368s 2368s Using the *connection_factory* parameter a different class or connections 2368s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_api_get_schema_dtypes(conn, request): 2369s if "adbc" in conn: 2369s request.node.add_marker( 2369s pytest.mark.xfail( 2369s reason="'get_schema' not implemented for ADBC drivers", 2369s strict=True, 2369s ) 2369s ) 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2161: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ________________ test_api_get_schema_keys[mysql_pymysql_engine] ________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_api_get_schema_keys(conn, request, test_frame1): 2369s if "adbc" in conn: 2369s request.node.add_marker( 2369s pytest.mark.xfail( 2369s reason="'get_schema' not implemented for ADBC drivers", 2369s strict=True, 2369s ) 2369s ) 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s frame = DataFrame({"Col1": [1.1, 1.2], "Col2": [2.1, 2.2]}) 2369s > create_sql = sql.get_schema(frame, "test", con=conn, keys="Col1") 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2187: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2369s with pandasSQL_builder(con=con) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _________________ test_api_get_schema_keys[mysql_pymysql_conn] _________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_api_get_schema_keys(conn, request, test_frame1): 2369s if "adbc" in conn: 2369s request.node.add_marker( 2369s pytest.mark.xfail( 2369s reason="'get_schema' not implemented for ADBC drivers", 2369s strict=True, 2369s ) 2369s ) 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2185: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _____________ test_api_get_schema_keys[postgresql_psycopg2_engine] _____________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_api_get_schema_keys(conn, request, test_frame1): 2369s if "adbc" in conn: 2369s request.node.add_marker( 2369s pytest.mark.xfail( 2369s reason="'get_schema' not implemented for ADBC drivers", 2369s strict=True, 2369s ) 2369s ) 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s frame = DataFrame({"Col1": [1.1, 1.2], "Col2": [2.1, 2.2]}) 2369s > create_sql = sql.get_schema(frame, "test", con=conn, keys="Col1") 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2187: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2369s with pandasSQL_builder(con=con) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ______________ test_api_get_schema_keys[postgresql_psycopg2_conn] ______________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_api_get_schema_keys(conn, request, test_frame1): 2369s if "adbc" in conn: 2369s request.node.add_marker( 2369s pytest.mark.xfail( 2369s reason="'get_schema' not implemented for ADBC drivers", 2369s strict=True, 2369s ) 2369s ) 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2185: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ________________ test_api_chunksize_read[mysql_pymysql_engine] _________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_api_chunksize_read(conn, request): 2369s if "adbc" in conn: 2369s request.node.add_marker( 2369s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2369s ) 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s > if sql.has_table("test_chunksize", conn): 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2212: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2369s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _________________ test_api_chunksize_read[mysql_pymysql_conn] __________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_api_chunksize_read(conn, request): 2369s if "adbc" in conn: 2369s request.node.add_marker( 2369s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2369s ) 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2211: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _____________ test_api_chunksize_read[postgresql_psycopg2_engine] ______________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_api_chunksize_read(conn, request): 2369s if "adbc" in conn: 2369s request.node.add_marker( 2369s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2369s ) 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s > if sql.has_table("test_chunksize", conn): 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2212: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2369s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ______________ test_api_chunksize_read[postgresql_psycopg2_conn] _______________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_api_chunksize_read(conn, request): 2369s if "adbc" in conn: 2369s request.node.add_marker( 2369s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2369s ) 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2211: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s __________________ test_api_categorical[mysql_pymysql_engine] __________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_api_categorical(conn, request): 2369s if conn == "postgresql_adbc_conn": 2369s adbc = import_optional_dependency("adbc_driver_postgresql", errors="ignore") 2369s if adbc is not None and Version(adbc.__version__) < Version("0.9.0"): 2369s request.node.add_marker( 2369s pytest.mark.xfail( 2369s reason="categorical dtype not implemented for ADBC postgres driver", 2369s strict=True, 2369s ) 2369s ) 2369s # GH8624 2369s # test that categorical gets written correctly as dense column 2369s conn = request.getfixturevalue(conn) 2369s > if sql.has_table("test_categorical", conn): 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2267: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2369s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ___________________ test_api_categorical[mysql_pymysql_conn] ___________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_api_categorical(conn, request): 2369s if conn == "postgresql_adbc_conn": 2369s adbc = import_optional_dependency("adbc_driver_postgresql", errors="ignore") 2369s if adbc is not None and Version(adbc.__version__) < Version("0.9.0"): 2369s request.node.add_marker( 2369s pytest.mark.xfail( 2369s reason="categorical dtype not implemented for ADBC postgres driver", 2369s strict=True, 2369s ) 2369s ) 2369s # GH8624 2369s # test that categorical gets written correctly as dense column 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2266: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _______________ test_api_categorical[postgresql_psycopg2_engine] _______________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_api_categorical(conn, request): 2369s if conn == "postgresql_adbc_conn": 2369s adbc = import_optional_dependency("adbc_driver_postgresql", errors="ignore") 2369s if adbc is not None and Version(adbc.__version__) < Version("0.9.0"): 2369s request.node.add_marker( 2369s pytest.mark.xfail( 2369s reason="categorical dtype not implemented for ADBC postgres driver", 2369s strict=True, 2369s ) 2369s ) 2369s # GH8624 2369s # test that categorical gets written correctly as dense column 2369s conn = request.getfixturevalue(conn) 2369s > if sql.has_table("test_categorical", conn): 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2267: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2369s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ________________ test_api_categorical[postgresql_psycopg2_conn] ________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_api_categorical(conn, request): 2369s if conn == "postgresql_adbc_conn": 2369s adbc = import_optional_dependency("adbc_driver_postgresql", errors="ignore") 2369s if adbc is not None and Version(adbc.__version__) < Version("0.9.0"): 2369s request.node.add_marker( 2369s pytest.mark.xfail( 2369s reason="categorical dtype not implemented for ADBC postgres driver", 2369s strict=True, 2369s ) 2369s ) 2369s # GH8624 2369s # test that categorical gets written correctly as dense column 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2266: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ______________ test_api_unicode_column_name[mysql_pymysql_engine] ______________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_api_unicode_column_name(conn, request): 2369s # GH 11431 2369s conn = request.getfixturevalue(conn) 2369s > if sql.has_table("test_unicode", conn): 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2290: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2369s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _______________ test_api_unicode_column_name[mysql_pymysql_conn] _______________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_api_unicode_column_name(conn, request): 2369s # GH 11431 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2289: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ___________ test_api_unicode_column_name[postgresql_psycopg2_engine] ___________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_api_unicode_column_name(conn, request): 2369s # GH 11431 2369s conn = request.getfixturevalue(conn) 2369s > if sql.has_table("test_unicode", conn): 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2290: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2369s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ____________ test_api_unicode_column_name[postgresql_psycopg2_conn] ____________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_api_unicode_column_name(conn, request): 2369s # GH 11431 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2289: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ______________ test_api_escaped_table_name[mysql_pymysql_engine] _______________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_api_escaped_table_name(conn, request): 2369s # GH 13206 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s > if sql.has_table("d1187b08-4943-4c8d-a7f6", conn): 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2303: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2369s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _______________ test_api_escaped_table_name[mysql_pymysql_conn] ________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_api_escaped_table_name(conn, request): 2369s # GH 13206 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2302: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ___________ test_api_escaped_table_name[postgresql_psycopg2_engine] ____________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_api_escaped_table_name(conn, request): 2369s # GH 13206 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s > if sql.has_table("d1187b08-4943-4c8d-a7f6", conn): 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2303: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2369s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ____________ test_api_escaped_table_name[postgresql_psycopg2_conn] _____________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_api_escaped_table_name(conn, request): 2369s # GH 13206 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2302: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s __________ test_api_read_sql_duplicate_columns[mysql_pymysql_engine] ___________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_api_read_sql_duplicate_columns(conn, request): 2369s # GH#53117 2369s if "adbc" in conn: 2369s pa = pytest.importorskip("pyarrow") 2369s if not ( 2369s Version(pa.__version__) >= Version("16.0") 2369s and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"] 2369s ): 2369s request.node.add_marker( 2369s pytest.mark.xfail( 2369s reason="pyarrow->pandas throws ValueError", strict=True 2369s ) 2369s ) 2369s conn = request.getfixturevalue(conn) 2369s > if sql.has_table("test_table", conn): 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2334: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2369s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ___________ test_api_read_sql_duplicate_columns[mysql_pymysql_conn] ____________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_api_read_sql_duplicate_columns(conn, request): 2369s # GH#53117 2369s if "adbc" in conn: 2369s pa = pytest.importorskip("pyarrow") 2369s if not ( 2369s Version(pa.__version__) >= Version("16.0") 2369s and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"] 2369s ): 2369s request.node.add_marker( 2369s pytest.mark.xfail( 2369s reason="pyarrow->pandas throws ValueError", strict=True 2369s ) 2369s ) 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2333: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _______ test_api_read_sql_duplicate_columns[postgresql_psycopg2_engine] ________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_api_read_sql_duplicate_columns(conn, request): 2369s # GH#53117 2369s if "adbc" in conn: 2369s pa = pytest.importorskip("pyarrow") 2369s if not ( 2369s Version(pa.__version__) >= Version("16.0") 2369s and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"] 2369s ): 2369s request.node.add_marker( 2369s pytest.mark.xfail( 2369s reason="pyarrow->pandas throws ValueError", strict=True 2369s ) 2369s ) 2369s conn = request.getfixturevalue(conn) 2369s > if sql.has_table("test_table", conn): 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2334: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 2369s with pandasSQL_builder(con, schema=schema) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ________ test_api_read_sql_duplicate_columns[postgresql_psycopg2_conn] _________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_api_read_sql_duplicate_columns(conn, request): 2369s # GH#53117 2369s if "adbc" in conn: 2369s pa = pytest.importorskip("pyarrow") 2369s if not ( 2369s Version(pa.__version__) >= Version("16.0") 2369s and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"] 2369s ): 2369s request.node.add_marker( 2369s pytest.mark.xfail( 2369s reason="pyarrow->pandas throws ValueError", strict=True 2369s ) 2369s ) 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2333: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ________________ test_read_table_columns[mysql_pymysql_engine] _________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_read_table_columns(conn, request, test_frame1): 2369s # test columns argument in read_table 2369s conn_name = conn 2369s if conn_name == "sqlite_buildin": 2369s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2369s 2369s conn = request.getfixturevalue(conn) 2369s > sql.to_sql(test_frame1, "test_frame", conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2357: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _________________ test_read_table_columns[mysql_pymysql_conn] __________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_read_table_columns(conn, request, test_frame1): 2369s # test columns argument in read_table 2369s conn_name = conn 2369s if conn_name == "sqlite_buildin": 2369s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2356: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _____________ test_read_table_columns[postgresql_psycopg2_engine] ______________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_read_table_columns(conn, request, test_frame1): 2369s # test columns argument in read_table 2369s conn_name = conn 2369s if conn_name == "sqlite_buildin": 2369s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2369s 2369s conn = request.getfixturevalue(conn) 2369s > sql.to_sql(test_frame1, "test_frame", conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2357: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ______________ test_read_table_columns[postgresql_psycopg2_conn] _______________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_read_table_columns(conn, request, test_frame1): 2369s # test columns argument in read_table 2369s conn_name = conn 2369s if conn_name == "sqlite_buildin": 2369s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2356: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _______________ test_read_table_index_col[mysql_pymysql_engine] ________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_read_table_index_col(conn, request, test_frame1): 2369s # test columns argument in read_table 2369s conn_name = conn 2369s if conn_name == "sqlite_buildin": 2369s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2369s 2369s conn = request.getfixturevalue(conn) 2369s > sql.to_sql(test_frame1, "test_frame", conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2373: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ________________ test_read_table_index_col[mysql_pymysql_conn] _________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_read_table_index_col(conn, request, test_frame1): 2369s # test columns argument in read_table 2369s conn_name = conn 2369s if conn_name == "sqlite_buildin": 2369s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2372: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ____________ test_read_table_index_col[postgresql_psycopg2_engine] _____________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_read_table_index_col(conn, request, test_frame1): 2369s # test columns argument in read_table 2369s conn_name = conn 2369s if conn_name == "sqlite_buildin": 2369s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2369s 2369s conn = request.getfixturevalue(conn) 2369s > sql.to_sql(test_frame1, "test_frame", conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2373: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _____________ test_read_table_index_col[postgresql_psycopg2_conn] ______________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_read_table_index_col(conn, request, test_frame1): 2369s # test columns argument in read_table 2369s conn_name = conn 2369s if conn_name == "sqlite_buildin": 2369s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2372: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ______________ test_read_sql_delegate[mysql_pymysql_engine_iris] _______________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_engine_iris' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable_iris) 2369s def test_read_sql_delegate(conn, request): 2369s if conn == "sqlite_buildin_iris": 2369s request.applymarker( 2369s pytest.mark.xfail( 2369s reason="sqlite_buildin connection does not implement read_sql_table" 2369s ) 2369s ) 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2397: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2369s create_and_load_iris(mysql_pymysql_engine, iris_path) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2369s with conn.begin() as con: 2369s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2369s return next(self.gen) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2369s with self.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _______________ test_read_sql_delegate[mysql_pymysql_conn_iris] ________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn_iris' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable_iris) 2369s def test_read_sql_delegate(conn, request): 2369s if conn == "sqlite_buildin_iris": 2369s request.applymarker( 2369s pytest.mark.xfail( 2369s reason="sqlite_buildin connection does not implement read_sql_table" 2369s ) 2369s ) 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2397: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2369s fixturedef = request._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2369s create_and_load_iris(mysql_pymysql_engine, iris_path) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2369s with conn.begin() as con: 2369s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2369s return next(self.gen) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2369s with self.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ___________ test_read_sql_delegate[postgresql_psycopg2_engine_iris] ____________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_engine_iris' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable_iris) 2369s def test_read_sql_delegate(conn, request): 2369s if conn == "sqlite_buildin_iris": 2369s request.applymarker( 2369s pytest.mark.xfail( 2369s reason="sqlite_buildin connection does not implement read_sql_table" 2369s ) 2369s ) 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2397: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2369s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2369s with conn.begin() as con: 2369s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2369s return next(self.gen) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2369s with self.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ____________ test_read_sql_delegate[postgresql_psycopg2_conn_iris] _____________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn_iris' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable_iris) 2369s def test_read_sql_delegate(conn, request): 2369s if conn == "sqlite_buildin_iris": 2369s request.applymarker( 2369s pytest.mark.xfail( 2369s reason="sqlite_buildin connection does not implement read_sql_table" 2369s ) 2369s ) 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2397: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2369s fixturedef = request._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2369s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2369s with conn.begin() as con: 2369s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2369s return next(self.gen) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2369s with self.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ________ test_warning_case_insensitive_table_name[mysql_pymysql_engine] ________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 2369s conn_name = conn 2369s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 2369s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 2369s 2369s conn = request.getfixturevalue(conn) 2369s # see gh-7815 2369s with tm.assert_produces_warning( 2369s UserWarning, 2369s match=( 2369s r"The provided table name 'TABLE1' is not found exactly as such in " 2369s r"the database after writing the table, possibly due to case " 2369s r"sensitivity issues. Consider using lower case table names." 2369s ), 2369s ): 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2448: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 2369s conn_name = conn 2369s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 2369s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 2369s 2369s conn = request.getfixturevalue(conn) 2369s # see gh-7815 2369s > with tm.assert_produces_warning( 2369s UserWarning, 2369s match=( 2369s r"The provided table name 'TABLE1' is not found exactly as such in " 2369s r"the database after writing the table, possibly due to case " 2369s r"sensitivity issues. Consider using lower case table names." 2369s ), 2369s ): 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2440: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/contextlib.py:162: in __exit__ 2369s self.gen.throw(value) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s def _assert_caught_expected_warning( 2369s *, 2369s caught_warnings: Sequence[warnings.WarningMessage], 2369s expected_warning: type[Warning], 2369s match: str | None, 2369s check_stacklevel: bool, 2369s ) -> None: 2369s """Assert that there was the expected warning among the caught warnings.""" 2369s saw_warning = False 2369s matched_message = False 2369s unmatched_messages = [] 2369s 2369s for actual_warning in caught_warnings: 2369s if issubclass(actual_warning.category, expected_warning): 2369s saw_warning = True 2369s 2369s if check_stacklevel: 2369s _assert_raised_with_correct_stacklevel(actual_warning) 2369s 2369s if match is not None: 2369s if re.search(match, str(actual_warning.message)): 2369s matched_message = True 2369s else: 2369s unmatched_messages.append(actual_warning.message) 2369s 2369s if not saw_warning: 2369s > raise AssertionError( 2369s f"Did not see expected warning of class " 2369s f"{repr(expected_warning.__name__)}" 2369s ) 2369s E AssertionError: Did not see expected warning of class 'UserWarning' 2369s 2369s /usr/lib/python3/dist-packages/pandas/_testing/_warnings.py:152: AssertionError 2369s _________ test_warning_case_insensitive_table_name[mysql_pymysql_conn] _________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 2369s conn_name = conn 2369s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 2369s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2438: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _____ test_warning_case_insensitive_table_name[postgresql_psycopg2_engine] _____ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 2369s conn_name = conn 2369s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 2369s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 2369s 2369s conn = request.getfixturevalue(conn) 2369s # see gh-7815 2369s with tm.assert_produces_warning( 2369s UserWarning, 2369s match=( 2369s r"The provided table name 'TABLE1' is not found exactly as such in " 2369s r"the database after writing the table, possibly due to case " 2369s r"sensitivity issues. Consider using lower case table names." 2369s ), 2369s ): 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2448: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 2369s conn_name = conn 2369s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 2369s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 2369s 2369s conn = request.getfixturevalue(conn) 2369s # see gh-7815 2369s > with tm.assert_produces_warning( 2369s UserWarning, 2369s match=( 2369s r"The provided table name 'TABLE1' is not found exactly as such in " 2369s r"the database after writing the table, possibly due to case " 2369s r"sensitivity issues. Consider using lower case table names." 2369s ), 2369s ): 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2440: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/contextlib.py:162: in __exit__ 2369s self.gen.throw(value) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s def _assert_caught_expected_warning( 2369s *, 2369s caught_warnings: Sequence[warnings.WarningMessage], 2369s expected_warning: type[Warning], 2369s match: str | None, 2369s check_stacklevel: bool, 2369s ) -> None: 2369s """Assert that there was the expected warning among the caught warnings.""" 2369s saw_warning = False 2369s matched_message = False 2369s unmatched_messages = [] 2369s 2369s for actual_warning in caught_warnings: 2369s if issubclass(actual_warning.category, expected_warning): 2369s saw_warning = True 2369s 2369s if check_stacklevel: 2369s _assert_raised_with_correct_stacklevel(actual_warning) 2369s 2369s if match is not None: 2369s if re.search(match, str(actual_warning.message)): 2369s matched_message = True 2369s else: 2369s unmatched_messages.append(actual_warning.message) 2369s 2369s if not saw_warning: 2369s > raise AssertionError( 2369s f"Did not see expected warning of class " 2369s f"{repr(expected_warning.__name__)}" 2369s ) 2369s E AssertionError: Did not see expected warning of class 'UserWarning' 2369s 2369s /usr/lib/python3/dist-packages/pandas/_testing/_warnings.py:152: AssertionError 2369s ______ test_warning_case_insensitive_table_name[postgresql_psycopg2_conn] ______ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 2369s conn_name = conn 2369s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 2369s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2438: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ______________ test_sqlalchemy_type_mapping[mysql_pymysql_engine] ______________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_sqlalchemy_type_mapping(conn, request): 2369s conn = request.getfixturevalue(conn) 2369s from sqlalchemy import TIMESTAMP 2369s 2369s # Test Timestamp objects (no datetime64 because of timezone) (GH9085) 2369s df = DataFrame( 2369s {"time": to_datetime(["2014-12-12 01:54", "2014-12-11 02:54"], utc=True)} 2369s ) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2465: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _______________ test_sqlalchemy_type_mapping[mysql_pymysql_conn] _______________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_sqlalchemy_type_mapping(conn, request): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2458: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ___________ test_sqlalchemy_type_mapping[postgresql_psycopg2_engine] ___________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_sqlalchemy_type_mapping(conn, request): 2369s conn = request.getfixturevalue(conn) 2369s from sqlalchemy import TIMESTAMP 2369s 2369s # Test Timestamp objects (no datetime64 because of timezone) (GH9085) 2369s df = DataFrame( 2369s {"time": to_datetime(["2014-12-12 01:54", "2014-12-11 02:54"], utc=True)} 2369s ) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2465: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ____________ test_sqlalchemy_type_mapping[postgresql_psycopg2_conn] ____________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_sqlalchemy_type_mapping(conn, request): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2458: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _____ test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_engine] ______ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s integer = 'int8', expected = 'SMALLINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ______ test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_conn] _______ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s integer = 'int8', expected = 'SMALLINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s __ test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_engine] ___ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s integer = 'int8', expected = 'SMALLINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___ test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_conn] ____ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s integer = 'int8', expected = 'SMALLINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _____ test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_engine] ______ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s integer = 'Int8', expected = 'SMALLINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ______ test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_conn] _______ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s integer = 'Int8', expected = 'SMALLINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s __ test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_engine] ___ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s integer = 'Int8', expected = 'SMALLINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___ test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_conn] ____ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s integer = 'Int8', expected = 'SMALLINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _____ test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_engine] _____ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s integer = 'uint8', expected = 'SMALLINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ______ test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_conn] ______ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s integer = 'uint8', expected = 'SMALLINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s __ test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_engine] __ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s integer = 'uint8', expected = 'SMALLINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___ test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_conn] ___ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s integer = 'uint8', expected = 'SMALLINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _____ test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_engine] _____ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s integer = 'UInt8', expected = 'SMALLINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ______ test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_conn] ______ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s integer = 'UInt8', expected = 'SMALLINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s __ test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_engine] __ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s integer = 'UInt8', expected = 'SMALLINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___ test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_conn] ___ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s integer = 'UInt8', expected = 'SMALLINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _____ test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_engine] _____ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s integer = 'int16', expected = 'SMALLINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ______ test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_conn] ______ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s integer = 'int16', expected = 'SMALLINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s __ test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_engine] __ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s integer = 'int16', expected = 'SMALLINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___ test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_conn] ___ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s integer = 'int16', expected = 'SMALLINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _____ test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_engine] _____ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s integer = 'Int16', expected = 'SMALLINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ______ test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_conn] ______ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s integer = 'Int16', expected = 'SMALLINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s __ test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_engine] __ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s integer = 'Int16', expected = 'SMALLINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___ test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_conn] ___ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s integer = 'Int16', expected = 'SMALLINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _____ test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_engine] _____ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s integer = 'uint16', expected = 'INTEGER' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ______ test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_conn] ______ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s integer = 'uint16', expected = 'INTEGER' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s __ test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_engine] __ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s integer = 'uint16', expected = 'INTEGER' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___ test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_conn] ___ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s integer = 'uint16', expected = 'INTEGER' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _____ test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_engine] _____ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s integer = 'UInt16', expected = 'INTEGER' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ______ test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_conn] ______ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s integer = 'UInt16', expected = 'INTEGER' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s __ test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_engine] __ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s integer = 'UInt16', expected = 'INTEGER' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___ test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_conn] ___ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s integer = 'UInt16', expected = 'INTEGER' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _____ test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_engine] ______ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s integer = 'int32', expected = 'INTEGER' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ______ test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_conn] _______ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s integer = 'int32', expected = 'INTEGER' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s __ test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_engine] ___ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s integer = 'int32', expected = 'INTEGER' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___ test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_conn] ____ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s integer = 'int32', expected = 'INTEGER' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _____ test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_engine] ______ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s integer = 'Int32', expected = 'INTEGER' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ______ test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_conn] _______ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s integer = 'Int32', expected = 'INTEGER' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s __ test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_engine] ___ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s integer = 'Int32', expected = 'INTEGER' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___ test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_conn] ____ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s integer = 'Int32', expected = 'INTEGER' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _____ test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_engine] ______ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s integer = 'uint32', expected = 'BIGINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ______ test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_conn] _______ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s integer = 'uint32', expected = 'BIGINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s __ test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_engine] ___ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s integer = 'uint32', expected = 'BIGINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___ test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_conn] ____ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s integer = 'uint32', expected = 'BIGINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _____ test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_engine] ______ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s integer = 'UInt32', expected = 'BIGINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ______ test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_conn] _______ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s integer = 'UInt32', expected = 'BIGINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s __ test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_engine] ___ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s integer = 'UInt32', expected = 'BIGINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___ test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_conn] ____ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s integer = 'UInt32', expected = 'BIGINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ______ test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_engine] ______ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s integer = 'int64', expected = 'BIGINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _______ test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_conn] _______ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s integer = 'int64', expected = 'BIGINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ___ test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_engine] ___ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s integer = 'int64', expected = 'BIGINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ____ test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_conn] ____ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s integer = 'int64', expected = 'BIGINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ______ test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_engine] ______ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s integer = 'Int64', expected = 'BIGINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _______ test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_conn] _______ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s integer = 'Int64', expected = 'BIGINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ___ test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_engine] ___ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s integer = 'Int64', expected = 'BIGINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ____ test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_conn] ____ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s integer = 'Int64', expected = 'BIGINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _______ test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_engine] _______ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s integer = , expected = 'BIGINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ________ test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_conn] ________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s integer = , expected = 'BIGINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ____ test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_engine] ____ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s integer = , expected = 'BIGINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _____ test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_conn] _____ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s integer = , expected = 'BIGINT' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "integer, expected", 2369s [ 2369s ("int8", "SMALLINT"), 2369s ("Int8", "SMALLINT"), 2369s ("uint8", "SMALLINT"), 2369s ("UInt8", "SMALLINT"), 2369s ("int16", "SMALLINT"), 2369s ("Int16", "SMALLINT"), 2369s ("uint16", "INTEGER"), 2369s ("UInt16", "INTEGER"), 2369s ("int32", "INTEGER"), 2369s ("Int32", "INTEGER"), 2369s ("uint32", "BIGINT"), 2369s ("UInt32", "BIGINT"), 2369s ("int64", "BIGINT"), 2369s ("Int64", "BIGINT"), 2369s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 2369s ], 2369s ) 2369s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ____ test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_engine] _____ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s integer = 'uint64' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2369s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2369s conn = request.getfixturevalue(conn) 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2509: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _____ test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_conn] ______ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s integer = 'uint64' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2369s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2506: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _ test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_engine] __ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s integer = 'uint64' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2369s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2369s conn = request.getfixturevalue(conn) 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2509: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s __ test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_conn] ___ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s integer = 'uint64' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2369s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2506: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ____ test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_engine] _____ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s integer = 'UInt64' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2369s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2369s conn = request.getfixturevalue(conn) 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2509: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _____ test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_conn] ______ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s integer = 'UInt64' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2369s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2506: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _ test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_engine] __ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s integer = 'UInt64' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2369s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2369s conn = request.getfixturevalue(conn) 2369s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 2369s df = DataFrame([0, 1], columns=["a"], dtype=integer) 2369s > with sql.SQLDatabase(conn) as db: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2509: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s __ test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_conn] ___ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s integer = 'UInt64' 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 2369s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2506: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _________________ test_database_uri_string[mysql_pymysql_conn] _________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_database_uri_string(conn, request, test_frame1): 2369s td.versioned_importorskip("sqlalchemy") 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2519: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ______________ test_database_uri_string[postgresql_psycopg2_conn] ______________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_database_uri_string(conn, request, test_frame1): 2369s td.versioned_importorskip("sqlalchemy") 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2519: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _________ test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_conn] _________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @td.skip_if_installed("pg8000") 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_pg8000_sqlalchemy_passthrough_error(conn, request): 2369s td.versioned_importorskip("sqlalchemy") 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2541: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ______ test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_conn] ______ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @td.skip_if_installed("pg8000") 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_pg8000_sqlalchemy_passthrough_error(conn, request): 2369s td.versioned_importorskip("sqlalchemy") 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2541: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ______________ test_query_by_text_obj[mysql_pymysql_engine_iris] _______________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_engine_iris' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2369s def test_query_by_text_obj(conn, request): 2369s # WIP : GH10846 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2553: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2369s create_and_load_iris(mysql_pymysql_engine, iris_path) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2369s with conn.begin() as con: 2369s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2369s return next(self.gen) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2369s with self.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _______________ test_query_by_text_obj[mysql_pymysql_conn_iris] ________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn_iris' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2369s def test_query_by_text_obj(conn, request): 2369s # WIP : GH10846 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2553: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2369s fixturedef = request._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2369s create_and_load_iris(mysql_pymysql_engine, iris_path) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2369s with conn.begin() as con: 2369s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2369s return next(self.gen) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2369s with self.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ___________ test_query_by_text_obj[postgresql_psycopg2_engine_iris] ____________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_engine_iris' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2369s def test_query_by_text_obj(conn, request): 2369s # WIP : GH10846 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2553: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2369s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2369s with conn.begin() as con: 2369s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2369s return next(self.gen) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2369s with self.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ____________ test_query_by_text_obj[postgresql_psycopg2_conn_iris] _____________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn_iris' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2369s def test_query_by_text_obj(conn, request): 2369s # WIP : GH10846 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2553: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2369s fixturedef = request._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2369s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2369s with conn.begin() as con: 2369s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2369s return next(self.gen) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2369s with self.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _____________ test_query_by_select_obj[mysql_pymysql_engine_iris] ______________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_engine_iris' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2369s def test_query_by_select_obj(conn, request): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2567: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2369s create_and_load_iris(mysql_pymysql_engine, iris_path) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2369s with conn.begin() as con: 2369s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2369s return next(self.gen) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2369s with self.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ______________ test_query_by_select_obj[mysql_pymysql_conn_iris] _______________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn_iris' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2369s def test_query_by_select_obj(conn, request): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2567: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2369s fixturedef = request._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2369s create_and_load_iris(mysql_pymysql_engine, iris_path) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2369s with conn.begin() as con: 2369s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2369s return next(self.gen) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2369s with self.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s __________ test_query_by_select_obj[postgresql_psycopg2_engine_iris] ___________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_engine_iris' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2369s def test_query_by_select_obj(conn, request): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2567: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2369s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2369s with conn.begin() as con: 2369s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2369s return next(self.gen) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2369s with self.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___________ test_query_by_select_obj[postgresql_psycopg2_conn_iris] ____________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn_iris' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2369s def test_query_by_select_obj(conn, request): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2567: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2369s fixturedef = request._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2369s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2369s with conn.begin() as con: 2369s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2369s return next(self.gen) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2369s with self.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ______________ test_column_with_percentage[mysql_pymysql_engine] _______________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_column_with_percentage(conn, request): 2369s # GH 37157 2369s conn_name = conn 2369s if conn_name == "sqlite_buildin": 2369s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2369s 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame({"A": [0, 1, 2], "%_variation": [3, 4, 5]}) 2369s > df.to_sql(name="test_column_percentage", con=conn, index=False) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2590: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _______________ test_column_with_percentage[mysql_pymysql_conn] ________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_column_with_percentage(conn, request): 2369s # GH 37157 2369s conn_name = conn 2369s if conn_name == "sqlite_buildin": 2369s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2588: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ___________ test_column_with_percentage[postgresql_psycopg2_engine] ____________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_column_with_percentage(conn, request): 2369s # GH 37157 2369s conn_name = conn 2369s if conn_name == "sqlite_buildin": 2369s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2369s 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame({"A": [0, 1, 2], "%_variation": [3, 4, 5]}) 2369s > df.to_sql(name="test_column_percentage", con=conn, index=False) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2590: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ____________ test_column_with_percentage[postgresql_psycopg2_conn] _____________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_column_with_percentage(conn, request): 2369s # GH 37157 2369s conn_name = conn 2369s if conn_name == "sqlite_buildin": 2369s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2588: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___________________ test_create_table[mysql_pymysql_engine] ____________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_create_table(conn, request): 2369s if conn == "sqlite_str": 2369s pytest.skip("sqlite_str has no inspection system") 2369s 2369s conn = request.getfixturevalue(conn) 2369s 2369s from sqlalchemy import inspect 2369s 2369s temp_frame = DataFrame({"one": [1.0, 2.0, 3.0, 4.0], "two": [4.0, 3.0, 2.0, 1.0]}) 2369s > with sql.SQLDatabase(conn, need_transaction=True) as pandasSQL: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2681: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ____________________ test_create_table[mysql_pymysql_conn] _____________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_create_table(conn, request): 2369s if conn == "sqlite_str": 2369s pytest.skip("sqlite_str has no inspection system") 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2676: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ________________ test_create_table[postgresql_psycopg2_engine] _________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_create_table(conn, request): 2369s if conn == "sqlite_str": 2369s pytest.skip("sqlite_str has no inspection system") 2369s 2369s conn = request.getfixturevalue(conn) 2369s 2369s from sqlalchemy import inspect 2369s 2369s temp_frame = DataFrame({"one": [1.0, 2.0, 3.0, 4.0], "two": [4.0, 3.0, 2.0, 1.0]}) 2369s > with sql.SQLDatabase(conn, need_transaction=True) as pandasSQL: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2681: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _________________ test_create_table[postgresql_psycopg2_conn] __________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_create_table(conn, request): 2369s if conn == "sqlite_str": 2369s pytest.skip("sqlite_str has no inspection system") 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2676: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ____________________ test_drop_table[mysql_pymysql_engine] _____________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_drop_table(conn, request): 2369s if conn == "sqlite_str": 2369s pytest.skip("sqlite_str has no inspection system") 2369s 2369s conn = request.getfixturevalue(conn) 2369s 2369s from sqlalchemy import inspect 2369s 2369s temp_frame = DataFrame({"one": [1.0, 2.0, 3.0, 4.0], "two": [4.0, 3.0, 2.0, 1.0]}) 2369s > with sql.SQLDatabase(conn) as pandasSQL: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2702: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _____________________ test_drop_table[mysql_pymysql_conn] ______________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_drop_table(conn, request): 2369s if conn == "sqlite_str": 2369s pytest.skip("sqlite_str has no inspection system") 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2697: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _________________ test_drop_table[postgresql_psycopg2_engine] __________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_drop_table(conn, request): 2369s if conn == "sqlite_str": 2369s pytest.skip("sqlite_str has no inspection system") 2369s 2369s conn = request.getfixturevalue(conn) 2369s 2369s from sqlalchemy import inspect 2369s 2369s temp_frame = DataFrame({"one": [1.0, 2.0, 3.0, 4.0], "two": [4.0, 3.0, 2.0, 1.0]}) 2369s > with sql.SQLDatabase(conn) as pandasSQL: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2702: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s __________________ test_drop_table[postgresql_psycopg2_conn] ___________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_drop_table(conn, request): 2369s if conn == "sqlite_str": 2369s pytest.skip("sqlite_str has no inspection system") 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2697: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _____________________ test_roundtrip[mysql_pymysql_engine] _____________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_roundtrip(conn, request, test_frame1): 2369s if conn == "sqlite_str": 2369s pytest.skip("sqlite_str has no inspection system") 2369s 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s > pandasSQL = pandasSQL_builder(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2725: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ______________________ test_roundtrip[mysql_pymysql_conn] ______________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_roundtrip(conn, request, test_frame1): 2369s if conn == "sqlite_str": 2369s pytest.skip("sqlite_str has no inspection system") 2369s 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2724: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s __________________ test_roundtrip[postgresql_psycopg2_engine] __________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_roundtrip(conn, request, test_frame1): 2369s if conn == "sqlite_str": 2369s pytest.skip("sqlite_str has no inspection system") 2369s 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s > pandasSQL = pandasSQL_builder(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2725: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___________________ test_roundtrip[postgresql_psycopg2_conn] ___________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_roundtrip(conn, request, test_frame1): 2369s if conn == "sqlite_str": 2369s pytest.skip("sqlite_str has no inspection system") 2369s 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2724: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _________________ test_execute_sql[mysql_pymysql_engine_iris] __________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_engine_iris' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable_iris) 2369s def test_execute_sql(conn, request): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2742: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2369s create_and_load_iris(mysql_pymysql_engine, iris_path) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2369s with conn.begin() as con: 2369s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2369s return next(self.gen) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2369s with self.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s __________________ test_execute_sql[mysql_pymysql_conn_iris] ___________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn_iris' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable_iris) 2369s def test_execute_sql(conn, request): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2742: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2369s fixturedef = request._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2369s create_and_load_iris(mysql_pymysql_engine, iris_path) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2369s with conn.begin() as con: 2369s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2369s return next(self.gen) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2369s with self.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ______________ test_execute_sql[postgresql_psycopg2_engine_iris] _______________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_engine_iris' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable_iris) 2369s def test_execute_sql(conn, request): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2742: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2369s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2369s with conn.begin() as con: 2369s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2369s return next(self.gen) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2369s with self.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _______________ test_execute_sql[postgresql_psycopg2_conn_iris] ________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn_iris' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable_iris) 2369s def test_execute_sql(conn, request): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2742: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2369s fixturedef = request._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2369s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2369s with conn.begin() as con: 2369s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2369s return next(self.gen) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2369s with self.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ____________ test_sqlalchemy_read_table[mysql_pymysql_engine_iris] _____________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_engine_iris' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2369s def test_sqlalchemy_read_table(conn, request): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2753: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2369s create_and_load_iris(mysql_pymysql_engine, iris_path) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2369s with conn.begin() as con: 2369s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2369s return next(self.gen) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2369s with self.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _____________ test_sqlalchemy_read_table[mysql_pymysql_conn_iris] ______________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn_iris' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2369s def test_sqlalchemy_read_table(conn, request): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2753: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2369s fixturedef = request._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2369s create_and_load_iris(mysql_pymysql_engine, iris_path) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2369s with conn.begin() as con: 2369s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2369s return next(self.gen) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2369s with self.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _________ test_sqlalchemy_read_table[postgresql_psycopg2_engine_iris] __________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_engine_iris' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2369s def test_sqlalchemy_read_table(conn, request): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2753: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2369s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2369s with conn.begin() as con: 2369s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2369s return next(self.gen) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2369s with self.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s __________ test_sqlalchemy_read_table[postgresql_psycopg2_conn_iris] ___________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn_iris' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2369s def test_sqlalchemy_read_table(conn, request): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2753: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2369s fixturedef = request._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2369s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2369s with conn.begin() as con: 2369s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2369s return next(self.gen) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2369s with self.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ________ test_sqlalchemy_read_table_columns[mysql_pymysql_engine_iris] _________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_engine_iris' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2369s def test_sqlalchemy_read_table_columns(conn, request): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2760: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2369s create_and_load_iris(mysql_pymysql_engine, iris_path) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2369s with conn.begin() as con: 2369s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2369s return next(self.gen) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2369s with self.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _________ test_sqlalchemy_read_table_columns[mysql_pymysql_conn_iris] __________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn_iris' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2369s def test_sqlalchemy_read_table_columns(conn, request): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2760: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2369s fixturedef = request._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2369s create_and_load_iris(mysql_pymysql_engine, iris_path) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2369s with conn.begin() as con: 2369s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2369s return next(self.gen) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2369s with self.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _____ test_sqlalchemy_read_table_columns[postgresql_psycopg2_engine_iris] ______ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_engine_iris' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2369s def test_sqlalchemy_read_table_columns(conn, request): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2760: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2369s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2369s with conn.begin() as con: 2369s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2369s return next(self.gen) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2369s with self.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ______ test_sqlalchemy_read_table_columns[postgresql_psycopg2_conn_iris] _______ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn_iris' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2369s def test_sqlalchemy_read_table_columns(conn, request): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2760: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2369s fixturedef = request._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2369s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2369s with conn.begin() as con: 2369s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2369s return next(self.gen) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2369s with self.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___________ test_read_table_absent_raises[mysql_pymysql_engine_iris] ___________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_engine_iris' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2369s def test_read_table_absent_raises(conn, request): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2769: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2369s create_and_load_iris(mysql_pymysql_engine, iris_path) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2369s with conn.begin() as con: 2369s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2369s return next(self.gen) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2369s with self.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ____________ test_read_table_absent_raises[mysql_pymysql_conn_iris] ____________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn_iris' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2369s def test_read_table_absent_raises(conn, request): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2769: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2369s fixturedef = request._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 2369s create_and_load_iris(mysql_pymysql_engine, iris_path) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2369s with conn.begin() as con: 2369s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2369s return next(self.gen) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2369s with self.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ________ test_read_table_absent_raises[postgresql_psycopg2_engine_iris] ________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_engine_iris' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2369s def test_read_table_absent_raises(conn, request): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2769: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2369s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2369s with conn.begin() as con: 2369s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2369s return next(self.gen) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2369s with self.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _________ test_read_table_absent_raises[postgresql_psycopg2_conn_iris] _________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn_iris' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 2369s def test_read_table_absent_raises(conn, request): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2769: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2369s fixturedef = request._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 2369s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 2369s with conn.begin() as con: 2369s /usr/lib/python3.13/contextlib.py:141: in __enter__ 2369s return next(self.gen) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 2369s with self.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s __ test_sqlalchemy_default_type_conversion[postgresql_psycopg2_engine_types] ___ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_engine_types' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2369s def test_sqlalchemy_default_type_conversion(conn, request): 2369s conn_name = conn 2369s if conn_name == "sqlite_str": 2369s pytest.skip("types tables not created in sqlite_str fixture") 2369s elif "mysql" in conn_name or "sqlite" in conn_name: 2369s request.applymarker( 2369s pytest.mark.xfail(reason="boolean dtype not inferred properly") 2369s ) 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2785: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2369s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2369s with conn.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___ test_sqlalchemy_default_type_conversion[postgresql_psycopg2_conn_types] ____ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn_types' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2369s def test_sqlalchemy_default_type_conversion(conn, request): 2369s conn_name = conn 2369s if conn_name == "sqlite_str": 2369s pytest.skip("types tables not created in sqlite_str fixture") 2369s elif "mysql" in conn_name or "sqlite" in conn_name: 2369s request.applymarker( 2369s pytest.mark.xfail(reason="boolean dtype not inferred properly") 2369s ) 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2785: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2369s fixturedef = request._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2369s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2369s with conn.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ______________________ test_bigint[mysql_pymysql_engine] _______________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_bigint(conn, request): 2369s # int64 should be converted to BigInteger, GH7433 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame(data={"i64": [2**62]}) 2369s > assert df.to_sql(name="test_bigint", con=conn, index=False) == 1 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2803: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _______________________ test_bigint[mysql_pymysql_conn] ________________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_bigint(conn, request): 2369s # int64 should be converted to BigInteger, GH7433 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2801: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ___________________ test_bigint[postgresql_psycopg2_engine] ____________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_bigint(conn, request): 2369s # int64 should be converted to BigInteger, GH7433 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame(data={"i64": [2**62]}) 2369s > assert df.to_sql(name="test_bigint", con=conn, index=False) == 1 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2803: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ____________________ test_bigint[postgresql_psycopg2_conn] _____________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_bigint(conn, request): 2369s # int64 should be converted to BigInteger, GH7433 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2801: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ______________ test_default_date_load[mysql_pymysql_engine_types] ______________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_engine_types' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2369s def test_default_date_load(conn, request): 2369s conn_name = conn 2369s if conn_name == "sqlite_str": 2369s pytest.skip("types tables not created in sqlite_str fixture") 2369s elif "sqlite" in conn_name: 2369s request.applymarker( 2369s pytest.mark.xfail(reason="sqlite does not read date properly") 2369s ) 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2819: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2369s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2369s with conn.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _______________ test_default_date_load[mysql_pymysql_conn_types] _______________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn_types' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2369s def test_default_date_load(conn, request): 2369s conn_name = conn 2369s if conn_name == "sqlite_str": 2369s pytest.skip("types tables not created in sqlite_str fixture") 2369s elif "sqlite" in conn_name: 2369s request.applymarker( 2369s pytest.mark.xfail(reason="sqlite does not read date properly") 2369s ) 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2819: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2369s fixturedef = request._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2369s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2369s with conn.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ___________ test_default_date_load[postgresql_psycopg2_engine_types] ___________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_engine_types' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2369s def test_default_date_load(conn, request): 2369s conn_name = conn 2369s if conn_name == "sqlite_str": 2369s pytest.skip("types tables not created in sqlite_str fixture") 2369s elif "sqlite" in conn_name: 2369s request.applymarker( 2369s pytest.mark.xfail(reason="sqlite does not read date properly") 2369s ) 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2819: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2369s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2369s with conn.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ____________ test_default_date_load[postgresql_psycopg2_conn_types] ____________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn_types' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2369s def test_default_date_load(conn, request): 2369s conn_name = conn 2369s if conn_name == "sqlite_str": 2369s pytest.skip("types tables not created in sqlite_str fixture") 2369s elif "sqlite" in conn_name: 2369s request.applymarker( 2369s pytest.mark.xfail(reason="sqlite does not read date properly") 2369s ) 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2819: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2369s fixturedef = request._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2369s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2369s with conn.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ______ test_datetime_with_timezone_query[None-postgresql_psycopg2_engine] ______ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s parse_dates = None 2369s 2369s @pytest.mark.parametrize("conn", postgresql_connectable) 2369s @pytest.mark.parametrize("parse_dates", [None, ["DateColWithTz"]]) 2369s def test_datetime_with_timezone_query(conn, request, parse_dates): 2369s # edge case that converts postgresql datetime with time zone types 2369s # to datetime64[ns,psycopg2.tz.FixedOffsetTimezone..], which is ok 2369s # but should be more natural, so coerce to datetime64[ns] for now 2369s conn = request.getfixturevalue(conn) 2369s > expected = create_and_load_postgres_datetz(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2832: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:351: in create_and_load_postgres_datetz 2369s with conn.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _______ test_datetime_with_timezone_query[None-postgresql_psycopg2_conn] _______ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s parse_dates = None 2369s 2369s @pytest.mark.parametrize("conn", postgresql_connectable) 2369s @pytest.mark.parametrize("parse_dates", [None, ["DateColWithTz"]]) 2369s def test_datetime_with_timezone_query(conn, request, parse_dates): 2369s # edge case that converts postgresql datetime with time zone types 2369s # to datetime64[ns,psycopg2.tz.FixedOffsetTimezone..], which is ok 2369s # but should be more natural, so coerce to datetime64[ns] for now 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2831: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s __ test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_engine] __ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s parse_dates = ['DateColWithTz'] 2369s 2369s @pytest.mark.parametrize("conn", postgresql_connectable) 2369s @pytest.mark.parametrize("parse_dates", [None, ["DateColWithTz"]]) 2369s def test_datetime_with_timezone_query(conn, request, parse_dates): 2369s # edge case that converts postgresql datetime with time zone types 2369s # to datetime64[ns,psycopg2.tz.FixedOffsetTimezone..], which is ok 2369s # but should be more natural, so coerce to datetime64[ns] for now 2369s conn = request.getfixturevalue(conn) 2369s > expected = create_and_load_postgres_datetz(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2832: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:351: in create_and_load_postgres_datetz 2369s with conn.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___ test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_conn] ___ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s parse_dates = ['DateColWithTz'] 2369s 2369s @pytest.mark.parametrize("conn", postgresql_connectable) 2369s @pytest.mark.parametrize("parse_dates", [None, ["DateColWithTz"]]) 2369s def test_datetime_with_timezone_query(conn, request, parse_dates): 2369s # edge case that converts postgresql datetime with time zone types 2369s # to datetime64[ns,psycopg2.tz.FixedOffsetTimezone..], which is ok 2369s # but should be more natural, so coerce to datetime64[ns] for now 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2831: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___ test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_engine] ____ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", postgresql_connectable) 2369s def test_datetime_with_timezone_query_chunksize(conn, request): 2369s conn = request.getfixturevalue(conn) 2369s > expected = create_and_load_postgres_datetz(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2843: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:351: in create_and_load_postgres_datetz 2369s with conn.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ____ test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_conn] _____ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", postgresql_connectable) 2369s def test_datetime_with_timezone_query_chunksize(conn, request): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2842: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ________ test_datetime_with_timezone_table[postgresql_psycopg2_engine] _________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", postgresql_connectable) 2369s def test_datetime_with_timezone_table(conn, request): 2369s conn = request.getfixturevalue(conn) 2369s > expected = create_and_load_postgres_datetz(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2856: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:351: in create_and_load_postgres_datetz 2369s with conn.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _________ test_datetime_with_timezone_table[postgresql_psycopg2_conn] __________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", postgresql_connectable) 2369s def test_datetime_with_timezone_table(conn, request): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2855: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _________ test_datetime_with_timezone_roundtrip[mysql_pymysql_engine] __________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_datetime_with_timezone_roundtrip(conn, request): 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s # GH 9086 2369s # Write datetimetz data to a db and read it back 2369s # For dbs that support timestamps with timezones, should get back UTC 2369s # otherwise naive data should be returned 2369s expected = DataFrame( 2369s {"A": date_range("2013-01-01 09:00:00", periods=3, tz="US/Pacific")} 2369s ) 2369s > assert expected.to_sql(name="test_datetime_tz", con=conn, index=False) == 3 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2872: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s __________ test_datetime_with_timezone_roundtrip[mysql_pymysql_conn] ___________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_datetime_with_timezone_roundtrip(conn, request): 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2864: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ______ test_datetime_with_timezone_roundtrip[postgresql_psycopg2_engine] _______ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_datetime_with_timezone_roundtrip(conn, request): 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s # GH 9086 2369s # Write datetimetz data to a db and read it back 2369s # For dbs that support timestamps with timezones, should get back UTC 2369s # otherwise naive data should be returned 2369s expected = DataFrame( 2369s {"A": date_range("2013-01-01 09:00:00", periods=3, tz="US/Pacific")} 2369s ) 2369s > assert expected.to_sql(name="test_datetime_tz", con=conn, index=False) == 3 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2872: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _______ test_datetime_with_timezone_roundtrip[postgresql_psycopg2_conn] ________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_datetime_with_timezone_roundtrip(conn, request): 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2864: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ______________ test_out_of_bounds_datetime[mysql_pymysql_engine] _______________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_out_of_bounds_datetime(conn, request): 2369s # GH 26761 2369s conn = request.getfixturevalue(conn) 2369s data = DataFrame({"date": datetime(9999, 1, 1)}, index=[0]) 2369s > assert data.to_sql(name="test_datetime_obb", con=conn, index=False) == 1 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2897: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _______________ test_out_of_bounds_datetime[mysql_pymysql_conn] ________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_out_of_bounds_datetime(conn, request): 2369s # GH 26761 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2895: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ___________ test_out_of_bounds_datetime[postgresql_psycopg2_engine] ____________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_out_of_bounds_datetime(conn, request): 2369s # GH 26761 2369s conn = request.getfixturevalue(conn) 2369s data = DataFrame({"date": datetime(9999, 1, 1)}, index=[0]) 2369s > assert data.to_sql(name="test_datetime_obb", con=conn, index=False) == 1 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2897: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ____________ test_out_of_bounds_datetime[postgresql_psycopg2_conn] _____________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_out_of_bounds_datetime(conn, request): 2369s # GH 26761 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2895: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___________ test_naive_datetimeindex_roundtrip[mysql_pymysql_engine] ___________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_naive_datetimeindex_roundtrip(conn, request): 2369s # GH 23510 2369s # Ensure that a naive DatetimeIndex isn't converted to UTC 2369s conn = request.getfixturevalue(conn) 2369s dates = date_range("2018-01-01", periods=5, freq="6h")._with_freq(None) 2369s expected = DataFrame({"nums": range(5)}, index=dates) 2369s > assert expected.to_sql(name="foo_table", con=conn, index_label="info_date") == 5 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2910: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ____________ test_naive_datetimeindex_roundtrip[mysql_pymysql_conn] ____________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_naive_datetimeindex_roundtrip(conn, request): 2369s # GH 23510 2369s # Ensure that a naive DatetimeIndex isn't converted to UTC 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2907: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ________ test_naive_datetimeindex_roundtrip[postgresql_psycopg2_engine] ________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_naive_datetimeindex_roundtrip(conn, request): 2369s # GH 23510 2369s # Ensure that a naive DatetimeIndex isn't converted to UTC 2369s conn = request.getfixturevalue(conn) 2369s dates = date_range("2018-01-01", periods=5, freq="6h")._with_freq(None) 2369s expected = DataFrame({"nums": range(5)}, index=dates) 2369s > assert expected.to_sql(name="foo_table", con=conn, index_label="info_date") == 5 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2910: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _________ test_naive_datetimeindex_roundtrip[postgresql_psycopg2_conn] _________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_naive_datetimeindex_roundtrip(conn, request): 2369s # GH 23510 2369s # Ensure that a naive DatetimeIndex isn't converted to UTC 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2907: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ________________ test_date_parsing[mysql_pymysql_engine_types] _________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_engine_types' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2369s def test_date_parsing(conn, request): 2369s # No Parsing 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2920: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2369s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2369s with conn.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _________________ test_date_parsing[mysql_pymysql_conn_types] __________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn_types' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2369s def test_date_parsing(conn, request): 2369s # No Parsing 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2920: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2369s fixturedef = request._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 2369s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2369s with conn.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _____________ test_date_parsing[postgresql_psycopg2_engine_types] ______________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_engine_types' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2369s def test_date_parsing(conn, request): 2369s # No Parsing 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2920: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2369s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2369s with conn.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ______________ test_date_parsing[postgresql_psycopg2_conn_types] _______________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn_types' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 2369s def test_date_parsing(conn, request): 2369s # No Parsing 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2920: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 2369s fixturedef = request._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 2369s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 2369s with conn.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _____________________ test_datetime[mysql_pymysql_engine] ______________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_datetime(conn, request): 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame( 2369s {"A": date_range("2013-01-01 09:00:00", periods=3), "B": np.arange(3.0)} 2369s ) 2369s > assert df.to_sql(name="test_datetime", con=conn) == 3 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2955: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ______________________ test_datetime[mysql_pymysql_conn] _______________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_datetime(conn, request): 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2951: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s __________________ test_datetime[postgresql_psycopg2_engine] ___________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_datetime(conn, request): 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame( 2369s {"A": date_range("2013-01-01 09:00:00", periods=3), "B": np.arange(3.0)} 2369s ) 2369s > assert df.to_sql(name="test_datetime", con=conn) == 3 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2955: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___________________ test_datetime[postgresql_psycopg2_conn] ____________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_datetime(conn, request): 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2951: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___________________ test_datetime_NaT[mysql_pymysql_engine] ____________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_datetime_NaT(conn, request): 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame( 2369s {"A": date_range("2013-01-01 09:00:00", periods=3), "B": np.arange(3.0)} 2369s ) 2369s df.loc[1, "A"] = np.nan 2369s > assert df.to_sql(name="test_datetime", con=conn, index=False) == 3 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2981: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ____________________ test_datetime_NaT[mysql_pymysql_conn] _____________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_datetime_NaT(conn, request): 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2976: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ________________ test_datetime_NaT[postgresql_psycopg2_engine] _________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_datetime_NaT(conn, request): 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame( 2369s {"A": date_range("2013-01-01 09:00:00", periods=3), "B": np.arange(3.0)} 2369s ) 2369s df.loc[1, "A"] = np.nan 2369s > assert df.to_sql(name="test_datetime", con=conn, index=False) == 3 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2981: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _________________ test_datetime_NaT[postgresql_psycopg2_conn] __________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_datetime_NaT(conn, request): 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2976: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___________________ test_datetime_date[mysql_pymysql_engine] ___________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_datetime_date(conn, request): 2369s # test support for datetime.date 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([date(2014, 1, 1), date(2014, 1, 2)], columns=["a"]) 2369s > assert df.to_sql(name="test_date", con=conn, index=False) == 2 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3002: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ____________________ test_datetime_date[mysql_pymysql_conn] ____________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_datetime_date(conn, request): 2369s # test support for datetime.date 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3000: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ________________ test_datetime_date[postgresql_psycopg2_engine] ________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_datetime_date(conn, request): 2369s # test support for datetime.date 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([date(2014, 1, 1), date(2014, 1, 2)], columns=["a"]) 2369s > assert df.to_sql(name="test_date", con=conn, index=False) == 2 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3002: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _________________ test_datetime_date[postgresql_psycopg2_conn] _________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_datetime_date(conn, request): 2369s # test support for datetime.date 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3000: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___________________ test_datetime_time[mysql_pymysql_engine] ___________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s sqlite_buildin = 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_datetime_time(conn, request, sqlite_buildin): 2369s # test support for datetime.time 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([time(9, 0, 0), time(9, 1, 30)], columns=["a"]) 2369s > assert df.to_sql(name="test_time", con=conn, index=False) == 2 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3016: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ____________________ test_datetime_time[mysql_pymysql_conn] ____________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s sqlite_buildin = 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_datetime_time(conn, request, sqlite_buildin): 2369s # test support for datetime.time 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3014: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ________________ test_datetime_time[postgresql_psycopg2_engine] ________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s sqlite_buildin = 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_datetime_time(conn, request, sqlite_buildin): 2369s # test support for datetime.time 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame([time(9, 0, 0), time(9, 1, 30)], columns=["a"]) 2369s > assert df.to_sql(name="test_time", con=conn, index=False) == 2 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3016: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _________________ test_datetime_time[postgresql_psycopg2_conn] _________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s sqlite_buildin = 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_datetime_time(conn, request, sqlite_buildin): 2369s # test support for datetime.time 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3014: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ________________ test_mixed_dtype_insert[mysql_pymysql_engine] _________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_mixed_dtype_insert(conn, request): 2369s # see GH6509 2369s conn = request.getfixturevalue(conn) 2369s s1 = Series(2**25 + 1, dtype=np.int32) 2369s s2 = Series(0.0, dtype=np.float32) 2369s df = DataFrame({"s1": s1, "s2": s2}) 2369s 2369s # write and read again 2369s > assert df.to_sql(name="test_read_write", con=conn, index=False) == 1 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3046: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _________________ test_mixed_dtype_insert[mysql_pymysql_conn] __________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_mixed_dtype_insert(conn, request): 2369s # see GH6509 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3040: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _____________ test_mixed_dtype_insert[postgresql_psycopg2_engine] ______________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_mixed_dtype_insert(conn, request): 2369s # see GH6509 2369s conn = request.getfixturevalue(conn) 2369s s1 = Series(2**25 + 1, dtype=np.int32) 2369s s2 = Series(0.0, dtype=np.float32) 2369s df = DataFrame({"s1": s1, "s2": s2}) 2369s 2369s # write and read again 2369s > assert df.to_sql(name="test_read_write", con=conn, index=False) == 1 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3046: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ______________ test_mixed_dtype_insert[postgresql_psycopg2_conn] _______________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_mixed_dtype_insert(conn, request): 2369s # see GH6509 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3040: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ____________________ test_nan_numeric[mysql_pymysql_engine] ____________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_nan_numeric(conn, request): 2369s # NaNs in numeric float column 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame({"A": [0, 1, 2], "B": [0.2, np.nan, 5.6]}) 2369s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3057: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _____________________ test_nan_numeric[mysql_pymysql_conn] _____________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_nan_numeric(conn, request): 2369s # NaNs in numeric float column 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3055: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _________________ test_nan_numeric[postgresql_psycopg2_engine] _________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_nan_numeric(conn, request): 2369s # NaNs in numeric float column 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame({"A": [0, 1, 2], "B": [0.2, np.nan, 5.6]}) 2369s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3057: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s __________________ test_nan_numeric[postgresql_psycopg2_conn] __________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_nan_numeric(conn, request): 2369s # NaNs in numeric float column 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3055: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s __________________ test_nan_fullcolumn[mysql_pymysql_engine] ___________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_nan_fullcolumn(conn, request): 2369s # full NaN column (numeric float column) 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame({"A": [0, 1, 2], "B": [np.nan, np.nan, np.nan]}) 2369s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3073: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ___________________ test_nan_fullcolumn[mysql_pymysql_conn] ____________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_nan_fullcolumn(conn, request): 2369s # full NaN column (numeric float column) 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3071: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _______________ test_nan_fullcolumn[postgresql_psycopg2_engine] ________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_nan_fullcolumn(conn, request): 2369s # full NaN column (numeric float column) 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame({"A": [0, 1, 2], "B": [np.nan, np.nan, np.nan]}) 2369s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3073: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ________________ test_nan_fullcolumn[postgresql_psycopg2_conn] _________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_nan_fullcolumn(conn, request): 2369s # full NaN column (numeric float column) 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3071: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ____________________ test_nan_string[mysql_pymysql_engine] _____________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_nan_string(conn, request): 2369s # NaNs in string column 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame({"A": [0, 1, 2], "B": ["a", "b", np.nan]}) 2369s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3091: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _____________________ test_nan_string[mysql_pymysql_conn] ______________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_nan_string(conn, request): 2369s # NaNs in string column 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3089: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _________________ test_nan_string[postgresql_psycopg2_engine] __________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_nan_string(conn, request): 2369s # NaNs in string column 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame({"A": [0, 1, 2], "B": ["a", "b", np.nan]}) 2369s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3091: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s __________________ test_nan_string[postgresql_psycopg2_conn] ___________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_nan_string(conn, request): 2369s # NaNs in string column 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3089: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _________________ test_to_sql_save_index[mysql_pymysql_engine] _________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_to_sql_save_index(conn, request): 2369s if "adbc" in conn: 2369s request.node.add_marker( 2369s pytest.mark.xfail( 2369s reason="ADBC implementation does not create index", strict=True 2369s ) 2369s ) 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame.from_records( 2369s [(1, 2.1, "line1"), (2, 1.5, "line2")], columns=["A", "B", "C"], index=["A"] 2369s ) 2369s 2369s tbl_name = "test_to_sql_saves_index" 2369s > with pandasSQL_builder(conn) as pandasSQL: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3120: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s __________________ test_to_sql_save_index[mysql_pymysql_conn] __________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_to_sql_save_index(conn, request): 2369s if "adbc" in conn: 2369s request.node.add_marker( 2369s pytest.mark.xfail( 2369s reason="ADBC implementation does not create index", strict=True 2369s ) 2369s ) 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3114: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ______________ test_to_sql_save_index[postgresql_psycopg2_engine] ______________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_to_sql_save_index(conn, request): 2369s if "adbc" in conn: 2369s request.node.add_marker( 2369s pytest.mark.xfail( 2369s reason="ADBC implementation does not create index", strict=True 2369s ) 2369s ) 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s df = DataFrame.from_records( 2369s [(1, 2.1, "line1"), (2, 1.5, "line2")], columns=["A", "B", "C"], index=["A"] 2369s ) 2369s 2369s tbl_name = "test_to_sql_saves_index" 2369s > with pandasSQL_builder(conn) as pandasSQL: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3120: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _______________ test_to_sql_save_index[postgresql_psycopg2_conn] _______________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_to_sql_save_index(conn, request): 2369s if "adbc" in conn: 2369s request.node.add_marker( 2369s pytest.mark.xfail( 2369s reason="ADBC implementation does not create index", strict=True 2369s ) 2369s ) 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3114: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___________________ test_transactions[mysql_pymysql_engine] ____________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_transactions(conn, request): 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s 2369s stmt = "CREATE TABLE test_trans (A INT, B TEXT)" 2369s if conn_name != "sqlite_buildin" and "adbc" not in conn_name: 2369s from sqlalchemy import text 2369s 2369s stmt = text(stmt) 2369s 2369s > with pandasSQL_builder(conn) as pandasSQL: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3156: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ____________________ test_transactions[mysql_pymysql_conn] _____________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_transactions(conn, request): 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3148: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ________________ test_transactions[postgresql_psycopg2_engine] _________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_transactions(conn, request): 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s 2369s stmt = "CREATE TABLE test_trans (A INT, B TEXT)" 2369s if conn_name != "sqlite_buildin" and "adbc" not in conn_name: 2369s from sqlalchemy import text 2369s 2369s stmt = text(stmt) 2369s 2369s > with pandasSQL_builder(conn) as pandasSQL: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3156: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _________________ test_transactions[postgresql_psycopg2_conn] __________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_transactions(conn, request): 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3148: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _______________ test_transaction_rollback[mysql_pymysql_engine] ________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_transaction_rollback(conn, request): 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s > with pandasSQL_builder(conn) as pandasSQL: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3165: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ________________ test_transaction_rollback[mysql_pymysql_conn] _________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_transaction_rollback(conn, request): 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3164: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ____________ test_transaction_rollback[postgresql_psycopg2_engine] _____________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_transaction_rollback(conn, request): 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s > with pandasSQL_builder(conn) as pandasSQL: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3165: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _____________ test_transaction_rollback[postgresql_psycopg2_conn] ______________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_transaction_rollback(conn, request): 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3164: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ______________ test_get_schema_create_table[mysql_pymysql_engine] ______________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s test_frame3 = index A B 2369s 0 2000-01-03 00:00:00 2147483647 -1.987670 2369s 1 2000-01-04 00:00:00 -29 -0.041232 2369s 2 2000-01-05 00:00:00 20000 0.731168 2369s 3 2000-01-06 00:00:00 -290867 1.567621 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_get_schema_create_table(conn, request, test_frame3): 2369s # Use a dataframe without a bool column, since MySQL converts bool to 2369s # TINYINT (which read_sql_table returns as an int and causes a dtype 2369s # mismatch) 2369s if conn == "sqlite_str": 2369s request.applymarker( 2369s pytest.mark.xfail(reason="test does not support sqlite_str fixture") 2369s ) 2369s 2369s conn = request.getfixturevalue(conn) 2369s 2369s from sqlalchemy import text 2369s from sqlalchemy.engine import Engine 2369s 2369s tbl = "test_get_schema_create_table" 2369s > create_sql = sql.get_schema(test_frame3, tbl, con=conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3219: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2369s with pandasSQL_builder(con=con) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _______________ test_get_schema_create_table[mysql_pymysql_conn] _______________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s test_frame3 = index A B 2369s 0 2000-01-03 00:00:00 2147483647 -1.987670 2369s 1 2000-01-04 00:00:00 -29 -0.041232 2369s 2 2000-01-05 00:00:00 20000 0.731168 2369s 3 2000-01-06 00:00:00 -290867 1.567621 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_get_schema_create_table(conn, request, test_frame3): 2369s # Use a dataframe without a bool column, since MySQL converts bool to 2369s # TINYINT (which read_sql_table returns as an int and causes a dtype 2369s # mismatch) 2369s if conn == "sqlite_str": 2369s request.applymarker( 2369s pytest.mark.xfail(reason="test does not support sqlite_str fixture") 2369s ) 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3213: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ___________ test_get_schema_create_table[postgresql_psycopg2_engine] ___________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s test_frame3 = index A B 2369s 0 2000-01-03 00:00:00 2147483647 -1.987670 2369s 1 2000-01-04 00:00:00 -29 -0.041232 2369s 2 2000-01-05 00:00:00 20000 0.731168 2369s 3 2000-01-06 00:00:00 -290867 1.567621 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_get_schema_create_table(conn, request, test_frame3): 2369s # Use a dataframe without a bool column, since MySQL converts bool to 2369s # TINYINT (which read_sql_table returns as an int and causes a dtype 2369s # mismatch) 2369s if conn == "sqlite_str": 2369s request.applymarker( 2369s pytest.mark.xfail(reason="test does not support sqlite_str fixture") 2369s ) 2369s 2369s conn = request.getfixturevalue(conn) 2369s 2369s from sqlalchemy import text 2369s from sqlalchemy.engine import Engine 2369s 2369s tbl = "test_get_schema_create_table" 2369s > create_sql = sql.get_schema(test_frame3, tbl, con=conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3219: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 2369s with pandasSQL_builder(con=con) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ____________ test_get_schema_create_table[postgresql_psycopg2_conn] ____________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s test_frame3 = index A B 2369s 0 2000-01-03 00:00:00 2147483647 -1.987670 2369s 1 2000-01-04 00:00:00 -29 -0.041232 2369s 2 2000-01-05 00:00:00 20000 0.731168 2369s 3 2000-01-06 00:00:00 -290867 1.567621 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_get_schema_create_table(conn, request, test_frame3): 2369s # Use a dataframe without a bool column, since MySQL converts bool to 2369s # TINYINT (which read_sql_table returns as an int and causes a dtype 2369s # mismatch) 2369s if conn == "sqlite_str": 2369s request.applymarker( 2369s pytest.mark.xfail(reason="test does not support sqlite_str fixture") 2369s ) 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3213: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _______________________ test_dtype[mysql_pymysql_engine] _______________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_dtype(conn, request): 2369s if conn == "sqlite_str": 2369s pytest.skip("sqlite_str has no inspection system") 2369s 2369s conn = request.getfixturevalue(conn) 2369s 2369s from sqlalchemy import ( 2369s TEXT, 2369s String, 2369s ) 2369s from sqlalchemy.schema import MetaData 2369s 2369s cols = ["A", "B"] 2369s data = [(0.8, True), (0.9, None)] 2369s df = DataFrame(data, columns=cols) 2369s > assert df.to_sql(name="dtype_test", con=conn) == 2 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3249: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ________________________ test_dtype[mysql_pymysql_conn] ________________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_dtype(conn, request): 2369s if conn == "sqlite_str": 2369s pytest.skip("sqlite_str has no inspection system") 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3238: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ____________________ test_dtype[postgresql_psycopg2_engine] ____________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_dtype(conn, request): 2369s if conn == "sqlite_str": 2369s pytest.skip("sqlite_str has no inspection system") 2369s 2369s conn = request.getfixturevalue(conn) 2369s 2369s from sqlalchemy import ( 2369s TEXT, 2369s String, 2369s ) 2369s from sqlalchemy.schema import MetaData 2369s 2369s cols = ["A", "B"] 2369s data = [(0.8, True), (0.9, None)] 2369s df = DataFrame(data, columns=cols) 2369s > assert df.to_sql(name="dtype_test", con=conn) == 2 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3249: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _____________________ test_dtype[postgresql_psycopg2_conn] _____________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_dtype(conn, request): 2369s if conn == "sqlite_str": 2369s pytest.skip("sqlite_str has no inspection system") 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3238: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ____________________ test_notna_dtype[mysql_pymysql_engine] ____________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_notna_dtype(conn, request): 2369s if conn == "sqlite_str": 2369s pytest.skip("sqlite_str has no inspection system") 2369s 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s 2369s from sqlalchemy import ( 2369s Boolean, 2369s DateTime, 2369s Float, 2369s Integer, 2369s ) 2369s from sqlalchemy.schema import MetaData 2369s 2369s cols = { 2369s "Bool": Series([True, None]), 2369s "Date": Series([datetime(2012, 5, 1), None]), 2369s "Int": Series([1, None], dtype="object"), 2369s "Float": Series([1.1, None]), 2369s } 2369s df = DataFrame(cols) 2369s 2369s tbl = "notna_dtype_test" 2369s > assert df.to_sql(name=tbl, con=conn) == 2 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3300: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _____________________ test_notna_dtype[mysql_pymysql_conn] _____________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_notna_dtype(conn, request): 2369s if conn == "sqlite_str": 2369s pytest.skip("sqlite_str has no inspection system") 2369s 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3281: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _________________ test_notna_dtype[postgresql_psycopg2_engine] _________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_notna_dtype(conn, request): 2369s if conn == "sqlite_str": 2369s pytest.skip("sqlite_str has no inspection system") 2369s 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s 2369s from sqlalchemy import ( 2369s Boolean, 2369s DateTime, 2369s Float, 2369s Integer, 2369s ) 2369s from sqlalchemy.schema import MetaData 2369s 2369s cols = { 2369s "Bool": Series([True, None]), 2369s "Date": Series([datetime(2012, 5, 1), None]), 2369s "Int": Series([1, None], dtype="object"), 2369s "Float": Series([1.1, None]), 2369s } 2369s df = DataFrame(cols) 2369s 2369s tbl = "notna_dtype_test" 2369s > assert df.to_sql(name=tbl, con=conn) == 2 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3300: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s __________________ test_notna_dtype[postgresql_psycopg2_conn] __________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_notna_dtype(conn, request): 2369s if conn == "sqlite_str": 2369s pytest.skip("sqlite_str has no inspection system") 2369s 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3281: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _________________ test_double_precision[mysql_pymysql_engine] __________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_double_precision(conn, request): 2369s if conn == "sqlite_str": 2369s pytest.skip("sqlite_str has no inspection system") 2369s 2369s conn = request.getfixturevalue(conn) 2369s 2369s from sqlalchemy import ( 2369s BigInteger, 2369s Float, 2369s Integer, 2369s ) 2369s from sqlalchemy.schema import MetaData 2369s 2369s V = 1.23456789101112131415 2369s 2369s df = DataFrame( 2369s { 2369s "f32": Series([V], dtype="float32"), 2369s "f64": Series([V], dtype="float64"), 2369s "f64_as_f32": Series([V], dtype="float64"), 2369s "i32": Series([5], dtype="int32"), 2369s "i64": Series([5], dtype="int64"), 2369s } 2369s ) 2369s 2369s assert ( 2369s > df.to_sql( 2369s name="test_dtypes", 2369s con=conn, 2369s index=False, 2369s if_exists="replace", 2369s dtype={"f64_as_f32": Float(precision=23)}, 2369s ) 2369s == 1 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3339: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s __________________ test_double_precision[mysql_pymysql_conn] ___________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_double_precision(conn, request): 2369s if conn == "sqlite_str": 2369s pytest.skip("sqlite_str has no inspection system") 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3317: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ______________ test_double_precision[postgresql_psycopg2_engine] _______________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_double_precision(conn, request): 2369s if conn == "sqlite_str": 2369s pytest.skip("sqlite_str has no inspection system") 2369s 2369s conn = request.getfixturevalue(conn) 2369s 2369s from sqlalchemy import ( 2369s BigInteger, 2369s Float, 2369s Integer, 2369s ) 2369s from sqlalchemy.schema import MetaData 2369s 2369s V = 1.23456789101112131415 2369s 2369s df = DataFrame( 2369s { 2369s "f32": Series([V], dtype="float32"), 2369s "f64": Series([V], dtype="float64"), 2369s "f64_as_f32": Series([V], dtype="float64"), 2369s "i32": Series([5], dtype="int32"), 2369s "i64": Series([5], dtype="int64"), 2369s } 2369s ) 2369s 2369s assert ( 2369s > df.to_sql( 2369s name="test_dtypes", 2369s con=conn, 2369s index=False, 2369s if_exists="replace", 2369s dtype={"f64_as_f32": Float(precision=23)}, 2369s ) 2369s == 1 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3339: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _______________ test_double_precision[postgresql_psycopg2_conn] ________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_double_precision(conn, request): 2369s if conn == "sqlite_str": 2369s pytest.skip("sqlite_str has no inspection system") 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3317: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _____________ test_connectable_issue_example[mysql_pymysql_engine] _____________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_connectable_issue_example(conn, request): 2369s conn = request.getfixturevalue(conn) 2369s 2369s # This tests the example raised in issue 2369s # https://github.com/pandas-dev/pandas/issues/10104 2369s from sqlalchemy.engine import Engine 2369s 2369s def test_select(connection): 2369s query = "SELECT test_foo_data FROM test_foo_data" 2369s return sql.read_sql_query(query, con=connection) 2369s 2369s def test_append(connection, data): 2369s data.to_sql(name="test_foo_data", con=connection, if_exists="append") 2369s 2369s def test_connectable(conn): 2369s # https://github.com/sqlalchemy/sqlalchemy/commit/ 2369s # 00b5c10846e800304caa86549ab9da373b42fa5d#r48323973 2369s foo_data = test_select(conn) 2369s test_append(conn, foo_data) 2369s 2369s def main(connectable): 2369s if isinstance(connectable, Engine): 2369s with connectable.connect() as conn: 2369s with conn.begin(): 2369s test_connectable(conn) 2369s else: 2369s test_connectable(connectable) 2369s 2369s assert ( 2369s > DataFrame({"test_foo_data": [0, 1, 2]}).to_sql(name="test_foo_data", con=conn) 2369s == 3 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3394: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ______________ test_connectable_issue_example[mysql_pymysql_conn] ______________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_connectable_issue_example(conn, request): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3366: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s __________ test_connectable_issue_example[postgresql_psycopg2_engine] __________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_connectable_issue_example(conn, request): 2369s conn = request.getfixturevalue(conn) 2369s 2369s # This tests the example raised in issue 2369s # https://github.com/pandas-dev/pandas/issues/10104 2369s from sqlalchemy.engine import Engine 2369s 2369s def test_select(connection): 2369s query = "SELECT test_foo_data FROM test_foo_data" 2369s return sql.read_sql_query(query, con=connection) 2369s 2369s def test_append(connection, data): 2369s data.to_sql(name="test_foo_data", con=connection, if_exists="append") 2369s 2369s def test_connectable(conn): 2369s # https://github.com/sqlalchemy/sqlalchemy/commit/ 2369s # 00b5c10846e800304caa86549ab9da373b42fa5d#r48323973 2369s foo_data = test_select(conn) 2369s test_append(conn, foo_data) 2369s 2369s def main(connectable): 2369s if isinstance(connectable, Engine): 2369s with connectable.connect() as conn: 2369s with conn.begin(): 2369s test_connectable(conn) 2369s else: 2369s test_connectable(connectable) 2369s 2369s assert ( 2369s > DataFrame({"test_foo_data": [0, 1, 2]}).to_sql(name="test_foo_data", con=conn) 2369s == 3 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3394: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___________ test_connectable_issue_example[postgresql_psycopg2_conn] ___________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_connectable_issue_example(conn, request): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3366: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _________ test_to_sql_with_negative_npinf[input0-mysql_pymysql_engine] _________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s input = {'foo': [inf]} 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "input", 2369s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2369s ) 2369s def test_to_sql_with_negative_npinf(conn, request, input): 2369s # GH 34431 2369s 2369s df = DataFrame(input) 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s 2369s if "mysql" in conn_name: 2369s # GH 36465 2369s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 2369s # for pymysql version >= 0.10 2369s # TODO(GH#36465): remove this version check after GH 36465 is fixed 2369s pymysql = td.versioned_importorskip("pymysql") 2369s 2369s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 2369s mark = pytest.mark.xfail(reason="GH 36465") 2369s request.applymarker(mark) 2369s 2369s msg = "inf cannot be used with MySQL" 2369s with pytest.raises(ValueError, match=msg): 2369s > df.to_sql(name="foobar", con=conn, index=False) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3425: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s __________ test_to_sql_with_negative_npinf[input0-mysql_pymysql_conn] __________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s input = {'foo': [inf]} 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "input", 2369s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2369s ) 2369s def test_to_sql_with_negative_npinf(conn, request, input): 2369s # GH 34431 2369s 2369s df = DataFrame(input) 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ______ test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_engine] ______ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s input = {'foo': [inf]} 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "input", 2369s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2369s ) 2369s def test_to_sql_with_negative_npinf(conn, request, input): 2369s # GH 34431 2369s 2369s df = DataFrame(input) 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s 2369s if "mysql" in conn_name: 2369s # GH 36465 2369s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 2369s # for pymysql version >= 0.10 2369s # TODO(GH#36465): remove this version check after GH 36465 is fixed 2369s pymysql = td.versioned_importorskip("pymysql") 2369s 2369s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 2369s mark = pytest.mark.xfail(reason="GH 36465") 2369s request.applymarker(mark) 2369s 2369s msg = "inf cannot be used with MySQL" 2369s with pytest.raises(ValueError, match=msg): 2369s df.to_sql(name="foobar", con=conn, index=False) 2369s else: 2369s > assert df.to_sql(name="foobar", con=conn, index=False) == 1 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3427: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _______ test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_conn] _______ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s input = {'foo': [inf]} 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "input", 2369s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2369s ) 2369s def test_to_sql_with_negative_npinf(conn, request, input): 2369s # GH 34431 2369s 2369s df = DataFrame(input) 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _________ test_to_sql_with_negative_npinf[input1-mysql_pymysql_engine] _________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s input = {'foo': [-inf]} 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "input", 2369s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2369s ) 2369s def test_to_sql_with_negative_npinf(conn, request, input): 2369s # GH 34431 2369s 2369s df = DataFrame(input) 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s 2369s if "mysql" in conn_name: 2369s # GH 36465 2369s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 2369s # for pymysql version >= 0.10 2369s # TODO(GH#36465): remove this version check after GH 36465 is fixed 2369s pymysql = td.versioned_importorskip("pymysql") 2369s 2369s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 2369s mark = pytest.mark.xfail(reason="GH 36465") 2369s request.applymarker(mark) 2369s 2369s msg = "inf cannot be used with MySQL" 2369s with pytest.raises(ValueError, match=msg): 2369s > df.to_sql(name="foobar", con=conn, index=False) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3425: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s __________ test_to_sql_with_negative_npinf[input1-mysql_pymysql_conn] __________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s input = {'foo': [-inf]} 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "input", 2369s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2369s ) 2369s def test_to_sql_with_negative_npinf(conn, request, input): 2369s # GH 34431 2369s 2369s df = DataFrame(input) 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ______ test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_engine] ______ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s input = {'foo': [-inf]} 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "input", 2369s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2369s ) 2369s def test_to_sql_with_negative_npinf(conn, request, input): 2369s # GH 34431 2369s 2369s df = DataFrame(input) 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s 2369s if "mysql" in conn_name: 2369s # GH 36465 2369s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 2369s # for pymysql version >= 0.10 2369s # TODO(GH#36465): remove this version check after GH 36465 is fixed 2369s pymysql = td.versioned_importorskip("pymysql") 2369s 2369s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 2369s mark = pytest.mark.xfail(reason="GH 36465") 2369s request.applymarker(mark) 2369s 2369s msg = "inf cannot be used with MySQL" 2369s with pytest.raises(ValueError, match=msg): 2369s df.to_sql(name="foobar", con=conn, index=False) 2369s else: 2369s > assert df.to_sql(name="foobar", con=conn, index=False) == 1 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3427: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _______ test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_conn] _______ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s input = {'foo': [-inf]} 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "input", 2369s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2369s ) 2369s def test_to_sql_with_negative_npinf(conn, request, input): 2369s # GH 34431 2369s 2369s df = DataFrame(input) 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _________ test_to_sql_with_negative_npinf[input2-mysql_pymysql_engine] _________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s input = {'foo': [-inf], 'infe0': ['bar']} 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "input", 2369s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2369s ) 2369s def test_to_sql_with_negative_npinf(conn, request, input): 2369s # GH 34431 2369s 2369s df = DataFrame(input) 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s 2369s if "mysql" in conn_name: 2369s # GH 36465 2369s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 2369s # for pymysql version >= 0.10 2369s # TODO(GH#36465): remove this version check after GH 36465 is fixed 2369s pymysql = td.versioned_importorskip("pymysql") 2369s 2369s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 2369s mark = pytest.mark.xfail(reason="GH 36465") 2369s request.applymarker(mark) 2369s 2369s msg = "inf cannot be used with MySQL" 2369s with pytest.raises(ValueError, match=msg): 2369s > df.to_sql(name="foobar", con=conn, index=False) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3425: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s __________ test_to_sql_with_negative_npinf[input2-mysql_pymysql_conn] __________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s input = {'foo': [-inf], 'infe0': ['bar']} 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "input", 2369s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2369s ) 2369s def test_to_sql_with_negative_npinf(conn, request, input): 2369s # GH 34431 2369s 2369s df = DataFrame(input) 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ______ test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_engine] ______ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s input = {'foo': [-inf], 'infe0': ['bar']} 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "input", 2369s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2369s ) 2369s def test_to_sql_with_negative_npinf(conn, request, input): 2369s # GH 34431 2369s 2369s df = DataFrame(input) 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s 2369s if "mysql" in conn_name: 2369s # GH 36465 2369s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 2369s # for pymysql version >= 0.10 2369s # TODO(GH#36465): remove this version check after GH 36465 is fixed 2369s pymysql = td.versioned_importorskip("pymysql") 2369s 2369s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 2369s mark = pytest.mark.xfail(reason="GH 36465") 2369s request.applymarker(mark) 2369s 2369s msg = "inf cannot be used with MySQL" 2369s with pytest.raises(ValueError, match=msg): 2369s df.to_sql(name="foobar", con=conn, index=False) 2369s else: 2369s > assert df.to_sql(name="foobar", con=conn, index=False) == 1 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3427: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _______ test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_conn] _______ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s input = {'foo': [-inf], 'infe0': ['bar']} 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s @pytest.mark.parametrize( 2369s "input", 2369s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 2369s ) 2369s def test_to_sql_with_negative_npinf(conn, request, input): 2369s # GH 34431 2369s 2369s df = DataFrame(input) 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s __________________ test_temporary_table[mysql_pymysql_engine] __________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_temporary_table(conn, request): 2369s if conn == "sqlite_str": 2369s pytest.skip("test does not work with str connection") 2369s 2369s conn = request.getfixturevalue(conn) 2369s 2369s from sqlalchemy import ( 2369s Column, 2369s Integer, 2369s Unicode, 2369s select, 2369s ) 2369s from sqlalchemy.orm import ( 2369s Session, 2369s declarative_base, 2369s ) 2369s 2369s test_data = "Hello, World!" 2369s expected = DataFrame({"spam": [test_data]}) 2369s Base = declarative_base() 2369s 2369s class Temporary(Base): 2369s __tablename__ = "temp_test" 2369s __table_args__ = {"prefixes": ["TEMPORARY"]} 2369s id = Column(Integer, primary_key=True) 2369s spam = Column(Unicode(30), nullable=False) 2369s 2369s with Session(conn) as session: 2369s with session.begin(): 2369s > conn = session.connection() 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3462: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:2094: in connection 2369s return self._connection_for_bind( 2369s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:2110: in _connection_for_bind 2369s return trans._connection_for_bind(engine, execution_options) 2369s :2: in _connection_for_bind 2369s ??? 2369s /usr/lib/python3/dist-packages/sqlalchemy/orm/state_changes.py:139: in _go 2369s ret_value = fn(self, *arg, **kw) 2369s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:1189: in _connection_for_bind 2369s conn = bind.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ___________________ test_temporary_table[mysql_pymysql_conn] ___________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_temporary_table(conn, request): 2369s if conn == "sqlite_str": 2369s pytest.skip("test does not work with str connection") 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3437: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _______________ test_temporary_table[postgresql_psycopg2_engine] _______________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_temporary_table(conn, request): 2369s if conn == "sqlite_str": 2369s pytest.skip("test does not work with str connection") 2369s 2369s conn = request.getfixturevalue(conn) 2369s 2369s from sqlalchemy import ( 2369s Column, 2369s Integer, 2369s Unicode, 2369s select, 2369s ) 2369s from sqlalchemy.orm import ( 2369s Session, 2369s declarative_base, 2369s ) 2369s 2369s test_data = "Hello, World!" 2369s expected = DataFrame({"spam": [test_data]}) 2369s Base = declarative_base() 2369s 2369s class Temporary(Base): 2369s __tablename__ = "temp_test" 2369s __table_args__ = {"prefixes": ["TEMPORARY"]} 2369s id = Column(Integer, primary_key=True) 2369s spam = Column(Unicode(30), nullable=False) 2369s 2369s with Session(conn) as session: 2369s with session.begin(): 2369s > conn = session.connection() 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3462: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:2094: in connection 2369s return self._connection_for_bind( 2369s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:2110: in _connection_for_bind 2369s return trans._connection_for_bind(engine, execution_options) 2369s :2: in _connection_for_bind 2369s ??? 2369s /usr/lib/python3/dist-packages/sqlalchemy/orm/state_changes.py:139: in _go 2369s ret_value = fn(self, *arg, **kw) 2369s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:1189: in _connection_for_bind 2369s conn = bind.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ________________ test_temporary_table[postgresql_psycopg2_conn] ________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_temporary_table(conn, request): 2369s if conn == "sqlite_str": 2369s pytest.skip("test does not work with str connection") 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3437: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s __________________ test_invalid_engine[mysql_pymysql_engine] ___________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_invalid_engine(conn, request, test_frame1): 2369s if conn == "sqlite_buildin" or "adbc" in conn: 2369s request.applymarker( 2369s pytest.mark.xfail( 2369s reason="SQLiteDatabase/ADBCDatabase does not raise for bad engine" 2369s ) 2369s ) 2369s 2369s conn = request.getfixturevalue(conn) 2369s msg = "engine must be one of 'auto', 'sqlalchemy'" 2369s > with pandasSQL_builder(conn) as pandasSQL: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3481: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ___________________ test_invalid_engine[mysql_pymysql_conn] ____________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_invalid_engine(conn, request, test_frame1): 2369s if conn == "sqlite_buildin" or "adbc" in conn: 2369s request.applymarker( 2369s pytest.mark.xfail( 2369s reason="SQLiteDatabase/ADBCDatabase does not raise for bad engine" 2369s ) 2369s ) 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3479: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _______________ test_invalid_engine[postgresql_psycopg2_engine] ________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_invalid_engine(conn, request, test_frame1): 2369s if conn == "sqlite_buildin" or "adbc" in conn: 2369s request.applymarker( 2369s pytest.mark.xfail( 2369s reason="SQLiteDatabase/ADBCDatabase does not raise for bad engine" 2369s ) 2369s ) 2369s 2369s conn = request.getfixturevalue(conn) 2369s msg = "engine must be one of 'auto', 'sqlalchemy'" 2369s > with pandasSQL_builder(conn) as pandasSQL: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3481: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ________________ test_invalid_engine[postgresql_psycopg2_conn] _________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_invalid_engine(conn, request, test_frame1): 2369s if conn == "sqlite_buildin" or "adbc" in conn: 2369s request.applymarker( 2369s pytest.mark.xfail( 2369s reason="SQLiteDatabase/ADBCDatabase does not raise for bad engine" 2369s ) 2369s ) 2369s 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3479: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ______________ test_to_sql_with_sql_engine[mysql_pymysql_engine] _______________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_to_sql_with_sql_engine(conn, request, test_frame1): 2369s """`to_sql` with the `engine` param""" 2369s # mostly copied from this class's `_to_sql()` method 2369s conn = request.getfixturevalue(conn) 2369s > with pandasSQL_builder(conn) as pandasSQL: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3491: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _______________ test_to_sql_with_sql_engine[mysql_pymysql_conn] ________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_to_sql_with_sql_engine(conn, request, test_frame1): 2369s """`to_sql` with the `engine` param""" 2369s # mostly copied from this class's `_to_sql()` method 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3490: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ___________ test_to_sql_with_sql_engine[postgresql_psycopg2_engine] ____________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_to_sql_with_sql_engine(conn, request, test_frame1): 2369s """`to_sql` with the `engine` param""" 2369s # mostly copied from this class's `_to_sql()` method 2369s conn = request.getfixturevalue(conn) 2369s > with pandasSQL_builder(conn) as pandasSQL: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3491: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ____________ test_to_sql_with_sql_engine[postgresql_psycopg2_conn] _____________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_to_sql_with_sql_engine(conn, request, test_frame1): 2369s """`to_sql` with the `engine` param""" 2369s # mostly copied from this class's `_to_sql()` method 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3490: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ________________ test_options_sqlalchemy[mysql_pymysql_engine] _________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_options_sqlalchemy(conn, request, test_frame1): 2369s # use the set option 2369s conn = request.getfixturevalue(conn) 2369s with pd.option_context("io.sql.engine", "sqlalchemy"): 2369s > with pandasSQL_builder(conn) as pandasSQL: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3506: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _________________ test_options_sqlalchemy[mysql_pymysql_conn] __________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_options_sqlalchemy(conn, request, test_frame1): 2369s # use the set option 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3504: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _____________ test_options_sqlalchemy[postgresql_psycopg2_engine] ______________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_options_sqlalchemy(conn, request, test_frame1): 2369s # use the set option 2369s conn = request.getfixturevalue(conn) 2369s with pd.option_context("io.sql.engine", "sqlalchemy"): 2369s > with pandasSQL_builder(conn) as pandasSQL: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3506: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ______________ test_options_sqlalchemy[postgresql_psycopg2_conn] _______________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 2369s def test_options_sqlalchemy(conn, request, test_frame1): 2369s # use the set option 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3504: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___________________ test_options_auto[mysql_pymysql_engine] ____________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_options_auto(conn, request, test_frame1): 2369s # use the set option 2369s conn = request.getfixturevalue(conn) 2369s with pd.option_context("io.sql.engine", "auto"): 2369s > with pandasSQL_builder(conn) as pandasSQL: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3521: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ____________________ test_options_auto[mysql_pymysql_conn] _____________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_options_auto(conn, request, test_frame1): 2369s # use the set option 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3519: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ________________ test_options_auto[postgresql_psycopg2_engine] _________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_options_auto(conn, request, test_frame1): 2369s # use the set option 2369s conn = request.getfixturevalue(conn) 2369s with pd.option_context("io.sql.engine", "auto"): 2369s > with pandasSQL_builder(conn) as pandasSQL: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3521: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _________________ test_options_auto[postgresql_psycopg2_conn] __________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s test_frame1 = index A B C D 2369s 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 2369s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_options_auto(conn, request, test_frame1): 2369s # use the set option 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3519: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_engine] _ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2369s dtype_backend_data = a b c d e f g h 2369s 0 1 1 1.5 1.5 True True a a 2369s 1 2 2.0 False False b b 2369s 2 3 3 2.5 2.5 None True c None 2369s dtype_backend_expected = .func at 0xe339beb37240> 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2369s def test_read_sql_dtype_backend( 2369s conn, 2369s request, 2369s string_storage, 2369s func, 2369s dtype_backend, 2369s dtype_backend_data, 2369s dtype_backend_expected, 2369s ): 2369s # GH#50048 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s table = "test" 2369s df = dtype_backend_data 2369s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3567: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_conn] _ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2369s dtype_backend_data = a b c d e f g h 2369s 0 1 1 1.5 1.5 True True a a 2369s 1 2 2.0 False False b b 2369s 2 3 3 2.5 2.5 None True c None 2369s dtype_backend_expected = .func at 0xe339beb37240> 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2369s def test_read_sql_dtype_backend( 2369s conn, 2369s request, 2369s string_storage, 2369s func, 2369s dtype_backend, 2369s dtype_backend_data, 2369s dtype_backend_expected, 2369s ): 2369s # GH#50048 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3564: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] _ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2369s dtype_backend_data = a b c d e f g h 2369s 0 1 1 1.5 1.5 True True a a 2369s 1 2 2.0 False False b b 2369s 2 3 3 2.5 2.5 None True c None 2369s dtype_backend_expected = .func at 0xe339beb37240> 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2369s def test_read_sql_dtype_backend( 2369s conn, 2369s request, 2369s string_storage, 2369s func, 2369s dtype_backend, 2369s dtype_backend_data, 2369s dtype_backend_expected, 2369s ): 2369s # GH#50048 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s table = "test" 2369s df = dtype_backend_data 2369s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3567: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] _ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2369s dtype_backend_data = a b c d e f g h 2369s 0 1 1 1.5 1.5 True True a a 2369s 1 2 2.0 False False b b 2369s 2 3 3 2.5 2.5 None True c None 2369s dtype_backend_expected = .func at 0xe339beb37240> 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2369s def test_read_sql_dtype_backend( 2369s conn, 2369s request, 2369s string_storage, 2369s func, 2369s dtype_backend, 2369s dtype_backend_data, 2369s dtype_backend_expected, 2369s ): 2369s # GH#50048 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3564: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_engine] _ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s string_storage = 'python', func = 'read_sql_query' 2369s dtype_backend = 'numpy_nullable' 2369s dtype_backend_data = a b c d e f g h 2369s 0 1 1 1.5 1.5 True True a a 2369s 1 2 2.0 False False b b 2369s 2 3 3 2.5 2.5 None True c None 2369s dtype_backend_expected = .func at 0xe339beb37380> 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2369s def test_read_sql_dtype_backend( 2369s conn, 2369s request, 2369s string_storage, 2369s func, 2369s dtype_backend, 2369s dtype_backend_data, 2369s dtype_backend_expected, 2369s ): 2369s # GH#50048 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s table = "test" 2369s df = dtype_backend_data 2369s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3567: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_conn] _ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s string_storage = 'python', func = 'read_sql_query' 2369s dtype_backend = 'numpy_nullable' 2369s dtype_backend_data = a b c d e f g h 2369s 0 1 1 1.5 1.5 True True a a 2369s 1 2 2.0 False False b b 2369s 2 3 3 2.5 2.5 None True c None 2369s dtype_backend_expected = .func at 0xe339beb37380> 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2369s def test_read_sql_dtype_backend( 2369s conn, 2369s request, 2369s string_storage, 2369s func, 2369s dtype_backend, 2369s dtype_backend_data, 2369s dtype_backend_expected, 2369s ): 2369s # GH#50048 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3564: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_engine] _ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s string_storage = 'python', func = 'read_sql_query' 2369s dtype_backend = 'numpy_nullable' 2369s dtype_backend_data = a b c d e f g h 2369s 0 1 1 1.5 1.5 True True a a 2369s 1 2 2.0 False False b b 2369s 2 3 3 2.5 2.5 None True c None 2369s dtype_backend_expected = .func at 0xe339beb37420> 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2369s def test_read_sql_dtype_backend( 2369s conn, 2369s request, 2369s string_storage, 2369s func, 2369s dtype_backend, 2369s dtype_backend_data, 2369s dtype_backend_expected, 2369s ): 2369s # GH#50048 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s table = "test" 2369s df = dtype_backend_data 2369s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3567: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_conn] _ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s string_storage = 'python', func = 'read_sql_query' 2369s dtype_backend = 'numpy_nullable' 2369s dtype_backend_data = a b c d e f g h 2369s 0 1 1 1.5 1.5 True True a a 2369s 1 2 2.0 False False b b 2369s 2 3 3 2.5 2.5 None True c None 2369s dtype_backend_expected = .func at 0xe339beb374c0> 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2369s def test_read_sql_dtype_backend( 2369s conn, 2369s request, 2369s string_storage, 2369s func, 2369s dtype_backend, 2369s dtype_backend_data, 2369s dtype_backend_expected, 2369s ): 2369s # GH#50048 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3564: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_engine] _ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2369s dtype_backend_data = a b c d e f g h 2369s 0 1 1 1.5 1.5 True True a a 2369s 1 2 2.0 False False b b 2369s 2 3 3 2.5 2.5 None True c None 2369s dtype_backend_expected = .func at 0xe339beb37740> 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2369s def test_read_sql_dtype_backend_table( 2369s conn, 2369s request, 2369s string_storage, 2369s func, 2369s dtype_backend, 2369s dtype_backend_data, 2369s dtype_backend_expected, 2369s ): 2369s if "sqlite" in conn and "adbc" not in conn: 2369s request.applymarker( 2369s pytest.mark.xfail( 2369s reason=( 2369s "SQLite actually returns proper boolean values via " 2369s "read_sql_table, but before pytest refactor was skipped" 2369s ) 2369s ) 2369s ) 2369s # GH#50048 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s table = "test" 2369s df = dtype_backend_data 2369s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3619: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_conn] _ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2369s dtype_backend_data = a b c d e f g h 2369s 0 1 1 1.5 1.5 True True a a 2369s 1 2 2.0 False False b b 2369s 2 3 3 2.5 2.5 None True c None 2369s dtype_backend_expected = .func at 0xe339beb37740> 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2369s def test_read_sql_dtype_backend_table( 2369s conn, 2369s request, 2369s string_storage, 2369s func, 2369s dtype_backend, 2369s dtype_backend_data, 2369s dtype_backend_expected, 2369s ): 2369s if "sqlite" in conn and "adbc" not in conn: 2369s request.applymarker( 2369s pytest.mark.xfail( 2369s reason=( 2369s "SQLite actually returns proper boolean values via " 2369s "read_sql_table, but before pytest refactor was skipped" 2369s ) 2369s ) 2369s ) 2369s # GH#50048 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3616: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] _ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2369s dtype_backend_data = a b c d e f g h 2369s 0 1 1 1.5 1.5 True True a a 2369s 1 2 2.0 False False b b 2369s 2 3 3 2.5 2.5 None True c None 2369s dtype_backend_expected = .func at 0xe339beb377e0> 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2369s def test_read_sql_dtype_backend_table( 2369s conn, 2369s request, 2369s string_storage, 2369s func, 2369s dtype_backend, 2369s dtype_backend_data, 2369s dtype_backend_expected, 2369s ): 2369s if "sqlite" in conn and "adbc" not in conn: 2369s request.applymarker( 2369s pytest.mark.xfail( 2369s reason=( 2369s "SQLite actually returns proper boolean values via " 2369s "read_sql_table, but before pytest refactor was skipped" 2369s ) 2369s ) 2369s ) 2369s # GH#50048 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s table = "test" 2369s df = dtype_backend_data 2369s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3619: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] _ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 2369s dtype_backend_data = a b c d e f g h 2369s 0 1 1 1.5 1.5 True True a a 2369s 1 2 2.0 False False b b 2369s 2 3 3 2.5 2.5 None True c None 2369s dtype_backend_expected = .func at 0xe339beb37880> 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2369s def test_read_sql_dtype_backend_table( 2369s conn, 2369s request, 2369s string_storage, 2369s func, 2369s dtype_backend, 2369s dtype_backend_data, 2369s dtype_backend_expected, 2369s ): 2369s if "sqlite" in conn and "adbc" not in conn: 2369s request.applymarker( 2369s pytest.mark.xfail( 2369s reason=( 2369s "SQLite actually returns proper boolean values via " 2369s "read_sql_table, but before pytest refactor was skipped" 2369s ) 2369s ) 2369s ) 2369s # GH#50048 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3616: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_engine] _ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s string_storage = 'python', func = 'read_sql_table' 2369s dtype_backend = 'numpy_nullable' 2369s dtype_backend_data = a b c d e f g h 2369s 0 1 1 1.5 1.5 True True a a 2369s 1 2 2.0 False False b b 2369s 2 3 3 2.5 2.5 None True c None 2369s dtype_backend_expected = .func at 0xe339beb37ce0> 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2369s def test_read_sql_dtype_backend_table( 2369s conn, 2369s request, 2369s string_storage, 2369s func, 2369s dtype_backend, 2369s dtype_backend_data, 2369s dtype_backend_expected, 2369s ): 2369s if "sqlite" in conn and "adbc" not in conn: 2369s request.applymarker( 2369s pytest.mark.xfail( 2369s reason=( 2369s "SQLite actually returns proper boolean values via " 2369s "read_sql_table, but before pytest refactor was skipped" 2369s ) 2369s ) 2369s ) 2369s # GH#50048 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s table = "test" 2369s df = dtype_backend_data 2369s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3619: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_conn] _ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s string_storage = 'python', func = 'read_sql_table' 2369s dtype_backend = 'numpy_nullable' 2369s dtype_backend_data = a b c d e f g h 2369s 0 1 1 1.5 1.5 True True a a 2369s 1 2 2.0 False False b b 2369s 2 3 3 2.5 2.5 None True c None 2369s dtype_backend_expected = .func at 0xe339beb37d80> 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2369s def test_read_sql_dtype_backend_table( 2369s conn, 2369s request, 2369s string_storage, 2369s func, 2369s dtype_backend, 2369s dtype_backend_data, 2369s dtype_backend_expected, 2369s ): 2369s if "sqlite" in conn and "adbc" not in conn: 2369s request.applymarker( 2369s pytest.mark.xfail( 2369s reason=( 2369s "SQLite actually returns proper boolean values via " 2369s "read_sql_table, but before pytest refactor was skipped" 2369s ) 2369s ) 2369s ) 2369s # GH#50048 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3616: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_engine] _ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s string_storage = 'python', func = 'read_sql_table' 2369s dtype_backend = 'numpy_nullable' 2369s dtype_backend_data = a b c d e f g h 2369s 0 1 1 1.5 1.5 True True a a 2369s 1 2 2.0 False False b b 2369s 2 3 3 2.5 2.5 None True c None 2369s dtype_backend_expected = .func at 0xe339beb37e20> 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2369s def test_read_sql_dtype_backend_table( 2369s conn, 2369s request, 2369s string_storage, 2369s func, 2369s dtype_backend, 2369s dtype_backend_data, 2369s dtype_backend_expected, 2369s ): 2369s if "sqlite" in conn and "adbc" not in conn: 2369s request.applymarker( 2369s pytest.mark.xfail( 2369s reason=( 2369s "SQLite actually returns proper boolean values via " 2369s "read_sql_table, but before pytest refactor was skipped" 2369s ) 2369s ) 2369s ) 2369s # GH#50048 2369s conn_name = conn 2369s conn = request.getfixturevalue(conn) 2369s table = "test" 2369s df = dtype_backend_data 2369s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3619: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_conn] _ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s string_storage = 'python', func = 'read_sql_table' 2369s dtype_backend = 'numpy_nullable' 2369s dtype_backend_data = a b c d e f g h 2369s 0 1 1 1.5 1.5 True True a a 2369s 1 2 2.0 False False b b 2369s 2 3 3 2.5 2.5 None True c None 2369s dtype_backend_expected = .func at 0xe339beb37ec0> 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 2369s def test_read_sql_dtype_backend_table( 2369s conn, 2369s request, 2369s string_storage, 2369s func, 2369s dtype_backend, 2369s dtype_backend_data, 2369s dtype_backend_expected, 2369s ): 2369s if "sqlite" in conn and "adbc" not in conn: 2369s request.applymarker( 2369s pytest.mark.xfail( 2369s reason=( 2369s "SQLite actually returns proper boolean values via " 2369s "read_sql_table, but before pytest refactor was skipped" 2369s ) 2369s ) 2369s ) 2369s # GH#50048 2369s conn_name = conn 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3616: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___ test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_engine] ___ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s func = 'read_sql' 2369s dtype_backend_data = a b c d e f g h 2369s 0 1 1 1.5 1.5 True True a a 2369s 1 2 2.0 False False b b 2369s 2 3 3 2.5 2.5 None True c None 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2369s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2369s conn = request.getfixturevalue(conn) 2369s table = "test" 2369s df = dtype_backend_data 2369s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ____ test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_conn] ____ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s func = 'read_sql' 2369s dtype_backend_data = a b c d e f g h 2369s 0 1 1 1.5 1.5 True True a a 2369s 1 2 2.0 False False b b 2369s 2 3 3 2.5 2.5 None True c None 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2369s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _ test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_engine] _ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s func = 'read_sql' 2369s dtype_backend_data = a b c d e f g h 2369s 0 1 1 1.5 1.5 True True a a 2369s 1 2 2.0 False False b b 2369s 2 3 3 2.5 2.5 None True c None 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2369s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2369s conn = request.getfixturevalue(conn) 2369s table = "test" 2369s df = dtype_backend_data 2369s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _ test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_conn] _ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s func = 'read_sql' 2369s dtype_backend_data = a b c d e f g h 2369s 0 1 1 1.5 1.5 True True a a 2369s 1 2 2.0 False False b b 2369s 2 3 3 2.5 2.5 None True c None 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2369s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _ test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_engine] _ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s func = 'read_sql_table' 2369s dtype_backend_data = a b c d e f g h 2369s 0 1 1 1.5 1.5 True True a a 2369s 1 2 2.0 False False b b 2369s 2 3 3 2.5 2.5 None True c None 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2369s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2369s conn = request.getfixturevalue(conn) 2369s table = "test" 2369s df = dtype_backend_data 2369s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _ test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_conn] _ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s func = 'read_sql_table' 2369s dtype_backend_data = a b c d e f g h 2369s 0 1 1 1.5 1.5 True True a a 2369s 1 2 2.0 False False b b 2369s 2 3 3 2.5 2.5 None True c None 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2369s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _ test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_engine] _ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s func = 'read_sql_table' 2369s dtype_backend_data = a b c d e f g h 2369s 0 1 1 1.5 1.5 True True a a 2369s 1 2 2.0 False False b b 2369s 2 3 3 2.5 2.5 None True c None 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2369s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2369s conn = request.getfixturevalue(conn) 2369s table = "test" 2369s df = dtype_backend_data 2369s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _ test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_conn] _ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s func = 'read_sql_table' 2369s dtype_backend_data = a b c d e f g h 2369s 0 1 1 1.5 1.5 True True a a 2369s 1 2 2.0 False False b b 2369s 2 3 3 2.5 2.5 None True c None 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2369s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _ test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_engine] _ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s func = 'read_sql_query' 2369s dtype_backend_data = a b c d e f g h 2369s 0 1 1 1.5 1.5 True True a a 2369s 1 2 2.0 False False b b 2369s 2 3 3 2.5 2.5 None True c None 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2369s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2369s conn = request.getfixturevalue(conn) 2369s table = "test" 2369s df = dtype_backend_data 2369s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _ test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_conn] _ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s func = 'read_sql_query' 2369s dtype_backend_data = a b c d e f g h 2369s 0 1 1 1.5 1.5 True True a a 2369s 1 2 2.0 False False b b 2369s 2 3 3 2.5 2.5 None True c None 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2369s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _ test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_engine] _ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s func = 'read_sql_query' 2369s dtype_backend_data = a b c d e f g h 2369s 0 1 1 1.5 1.5 True True a a 2369s 1 2 2.0 False False b b 2369s 2 3 3 2.5 2.5 None True c None 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2369s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2369s conn = request.getfixturevalue(conn) 2369s table = "test" 2369s df = dtype_backend_data 2369s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _ test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_conn] _ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s func = 'read_sql_query' 2369s dtype_backend_data = a b c d e f g h 2369s 0 1 1 1.5 1.5 True True a a 2369s 1 2 2.0 False False b b 2369s 2 3 3 2.5 2.5 None True c None 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 2369s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ______________ test_chunksize_empty_dtypes[mysql_pymysql_engine] _______________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_chunksize_empty_dtypes(conn, request): 2369s # GH#50245 2369s if "adbc" in conn: 2369s request.node.add_marker( 2369s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2369s ) 2369s conn = request.getfixturevalue(conn) 2369s dtypes = {"a": "int64", "b": "object"} 2369s df = DataFrame(columns=["a", "b"]).astype(dtypes) 2369s expected = df.copy() 2369s > df.to_sql(name="test", con=conn, index=False, if_exists="replace") 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3741: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _______________ test_chunksize_empty_dtypes[mysql_pymysql_conn] ________________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_chunksize_empty_dtypes(conn, request): 2369s # GH#50245 2369s if "adbc" in conn: 2369s request.node.add_marker( 2369s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2369s ) 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3737: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ___________ test_chunksize_empty_dtypes[postgresql_psycopg2_engine] ____________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_chunksize_empty_dtypes(conn, request): 2369s # GH#50245 2369s if "adbc" in conn: 2369s request.node.add_marker( 2369s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2369s ) 2369s conn = request.getfixturevalue(conn) 2369s dtypes = {"a": "int64", "b": "object"} 2369s df = DataFrame(columns=["a", "b"]).astype(dtypes) 2369s expected = df.copy() 2369s > df.to_sql(name="test", con=conn, index=False, if_exists="replace") 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3741: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ____________ test_chunksize_empty_dtypes[postgresql_psycopg2_conn] _____________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s def test_chunksize_empty_dtypes(conn, request): 2369s # GH#50245 2369s if "adbc" in conn: 2369s request.node.add_marker( 2369s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 2369s ) 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3737: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___ test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_engine] ___ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s func = 'read_sql', dtype_backend = 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2369s def test_read_sql_dtype(conn, request, func, dtype_backend): 2369s # GH#50797 2369s conn = request.getfixturevalue(conn) 2369s table = "test" 2369s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2369s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ____ test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_conn] ____ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s func = 'read_sql', dtype_backend = 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2369s def test_read_sql_dtype(conn, request, func, dtype_backend): 2369s # GH#50797 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _ test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_engine] _ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s func = 'read_sql', dtype_backend = 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2369s def test_read_sql_dtype(conn, request, func, dtype_backend): 2369s # GH#50797 2369s conn = request.getfixturevalue(conn) 2369s table = "test" 2369s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2369s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _ test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_conn] _ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s func = 'read_sql', dtype_backend = 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2369s def test_read_sql_dtype(conn, request, func, dtype_backend): 2369s # GH#50797 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ______ test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_engine] _______ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s func = 'read_sql', dtype_backend = 'numpy_nullable' 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2369s def test_read_sql_dtype(conn, request, func, dtype_backend): 2369s # GH#50797 2369s conn = request.getfixturevalue(conn) 2369s table = "test" 2369s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2369s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _______ test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_conn] ________ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s func = 'read_sql', dtype_backend = 'numpy_nullable' 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2369s def test_read_sql_dtype(conn, request, func, dtype_backend): 2369s # GH#50797 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ___ test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_engine] ____ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s func = 'read_sql', dtype_backend = 'numpy_nullable' 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2369s def test_read_sql_dtype(conn, request, func, dtype_backend): 2369s # GH#50797 2369s conn = request.getfixturevalue(conn) 2369s table = "test" 2369s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2369s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ____ test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_conn] _____ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s func = 'read_sql', dtype_backend = 'numpy_nullable' 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2369s def test_read_sql_dtype(conn, request, func, dtype_backend): 2369s # GH#50797 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _ test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_engine] _ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s func = 'read_sql_query', dtype_backend = 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2369s def test_read_sql_dtype(conn, request, func, dtype_backend): 2369s # GH#50797 2369s conn = request.getfixturevalue(conn) 2369s table = "test" 2369s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2369s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _ test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_conn] _ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s func = 'read_sql_query', dtype_backend = 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2369s def test_read_sql_dtype(conn, request, func, dtype_backend): 2369s # GH#50797 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _ test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_engine] _ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s func = 'read_sql_query', dtype_backend = 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2369s def test_read_sql_dtype(conn, request, func, dtype_backend): 2369s # GH#50797 2369s conn = request.getfixturevalue(conn) 2369s table = "test" 2369s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2369s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _ test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_conn] _ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s func = 'read_sql_query', dtype_backend = 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2369s def test_read_sql_dtype(conn, request, func, dtype_backend): 2369s # GH#50797 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s ___ test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_engine] ____ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 2369s request = > 2369s func = 'read_sql_query', dtype_backend = 'numpy_nullable' 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2369s def test_read_sql_dtype(conn, request, func, dtype_backend): 2369s # GH#50797 2369s conn = request.getfixturevalue(conn) 2369s table = "test" 2369s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2369s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s ____ test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_conn] _____ 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s > sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3.13/socket.py:864: in create_connection 2369s raise exceptions[0] 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s address = ('localhost', 3306), timeout = 10, source_address = None 2369s 2369s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 2369s source_address=None, *, all_errors=False): 2369s """Connect to *address* and return the socket object. 2369s 2369s Convenience function. Connect to *address* (a 2-tuple ``(host, 2369s port)``) and return the socket object. Passing the optional 2369s *timeout* parameter will set the timeout on the socket instance 2369s before attempting to connect. If no *timeout* is supplied, the 2369s global default timeout setting returned by :func:`getdefaulttimeout` 2369s is used. If *source_address* is set it must be a tuple of (host, port) 2369s for the socket to bind as a source address before making the connection. 2369s A host of '' or port 0 tells the OS to use the default. When a connection 2369s cannot be created, raises the last error if *all_errors* is False, 2369s and an ExceptionGroup of all errors if *all_errors* is True. 2369s """ 2369s 2369s host, port = address 2369s exceptions = [] 2369s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 2369s af, socktype, proto, canonname, sa = res 2369s sock = None 2369s try: 2369s sock = socket(af, socktype, proto) 2369s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 2369s sock.settimeout(timeout) 2369s if source_address: 2369s sock.bind(source_address) 2369s > sock.connect(sa) 2369s E ConnectionRefusedError: [Errno 111] Connection refused 2369s 2369s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 2369s 2369s During handling of the above exception, another exception occurred: 2369s 2369s self = 2369s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 2369s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'mysql_pymysql_conn' 2369s request = > 2369s func = 'read_sql_query', dtype_backend = 'numpy_nullable' 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2369s def test_read_sql_dtype(conn, request, func, dtype_backend): 2369s # GH#50797 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 2369s with mysql_pymysql_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 2369s self.connect() 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s self = , sock = None 2369s 2369s def connect(self, sock=None): 2369s self._closed = False 2369s try: 2369s if sock is None: 2369s if self.unix_socket: 2369s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 2369s sock.settimeout(self.connect_timeout) 2369s sock.connect(self.unix_socket) 2369s self.host_info = "Localhost via UNIX socket" 2369s self._secure = True 2369s if DEBUG: 2369s print("connected using unix_socket") 2369s else: 2369s kwargs = {} 2369s if self.bind_address is not None: 2369s kwargs["source_address"] = (self.bind_address, 0) 2369s while True: 2369s try: 2369s sock = socket.create_connection( 2369s (self.host, self.port), self.connect_timeout, **kwargs 2369s ) 2369s break 2369s except OSError as e: 2369s if e.errno == errno.EINTR: 2369s continue 2369s raise 2369s self.host_info = "socket %s:%d" % (self.host, self.port) 2369s if DEBUG: 2369s print("connected using socket") 2369s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 2369s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 2369s sock.settimeout(None) 2369s 2369s self._sock = sock 2369s self._rfile = sock.makefile("rb") 2369s self._next_seq_id = 0 2369s 2369s self._get_server_information() 2369s self._request_authentication() 2369s 2369s # Send "SET NAMES" query on init for: 2369s # - Ensure charaset (and collation) is set to the server. 2369s # - collation_id in handshake packet may be ignored. 2369s # - If collation is not specified, we don't know what is server's 2369s # default collation for the charset. For example, default collation 2369s # of utf8mb4 is: 2369s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 2369s # - MySQL 8.0: utf8mb4_0900_ai_ci 2369s # 2369s # Reference: 2369s # - https://github.com/PyMySQL/PyMySQL/issues/1092 2369s # - https://github.com/wagtail/wagtail/issues/9477 2369s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 2369s self.set_character_set(self.charset, self.collation) 2369s 2369s if self.sql_mode is not None: 2369s c = self.cursor() 2369s c.execute("SET sql_mode=%s", (self.sql_mode,)) 2369s c.close() 2369s 2369s if self.init_command is not None: 2369s c = self.cursor() 2369s c.execute(self.init_command) 2369s c.close() 2369s 2369s if self.autocommit_mode is not None: 2369s self.autocommit(self.autocommit_mode) 2369s except BaseException as e: 2369s self._rfile = None 2369s if sock is not None: 2369s try: 2369s sock.close() 2369s except: # noqa 2369s pass 2369s 2369s if isinstance(e, (OSError, IOError)): 2369s exc = err.OperationalError( 2369s CR.CR_CONN_HOST_ERROR, 2369s f"Can't connect to MySQL server on {self.host!r} ({e})", 2369s ) 2369s # Keep original exception and traceback to investigate error. 2369s exc.original_exception = e 2369s exc.traceback = traceback.format_exc() 2369s if DEBUG: 2369s print(exc.traceback) 2369s > raise exc 2369s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 2369s _ test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_engine] _ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s request = > 2369s func = 'read_sql_query', dtype_backend = 'numpy_nullable' 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2369s def test_read_sql_dtype(conn, request, func, dtype_backend): 2369s # GH#50797 2369s conn = request.getfixturevalue(conn) 2369s table = "test" 2369s df = DataFrame({"a": [1, 2, 3], "b": 5}) 2369s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 2369s return func(*args, **kwargs) 2369s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 2369s return sql.to_sql( 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 2369s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 2369s return SQLDatabase(con, schema, need_transaction) 2369s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 2369s con = self.exit_stack.enter_context(con.connect()) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _ test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_conn] __ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s conn = 'postgresql_psycopg2_conn' 2369s request = > 2369s func = 'read_sql_query', dtype_backend = 'numpy_nullable' 2369s 2369s @pytest.mark.parametrize("conn", all_connectable) 2369s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 2369s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 2369s def test_read_sql_dtype(conn, request, func, dtype_backend): 2369s # GH#50797 2369s > conn = request.getfixturevalue(conn) 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 2369s fixturedef = self._get_active_fixturedef(argname) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 2369s fixturedef.execute(request=subrequest) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 2369s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 2369s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 2369s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 2369s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 2369s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 2369s return (yield) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 2369s result = call_fixture_func(fixturefunc, request, kwargs) 2369s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 2369s fixture_result = next(generator) 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 2369s with postgresql_psycopg2_engine.connect() as conn: 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _________________________ test_psycopg2_schema_support _________________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s postgresql_psycopg2_engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s 2369s @pytest.mark.db 2369s def test_psycopg2_schema_support(postgresql_psycopg2_engine): 2369s conn = postgresql_psycopg2_engine 2369s 2369s # only test this for postgresql (schema's not supported in 2369s # mysql/sqlite) 2369s df = DataFrame({"col1": [1, 2], "col2": [0.1, 0.2], "col3": ["a", "n"]}) 2369s 2369s # create a schema 2369s > with conn.connect() as con: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3905: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s _________________________ test_self_join_date_columns __________________________ 2369s self = 2369s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s connection = None, _has_events = None, _allow_revalidate = True 2369s _allow_autobegin = True 2369s 2369s def __init__( 2369s self, 2369s engine: Engine, 2369s connection: Optional[PoolProxiedConnection] = None, 2369s _has_events: Optional[bool] = None, 2369s _allow_revalidate: bool = True, 2369s _allow_autobegin: bool = True, 2369s ): 2369s """Construct a new Connection.""" 2369s self.engine = engine 2369s self.dialect = dialect = engine.dialect 2369s 2369s if connection is None: 2369s try: 2369s > self._dbapi_connection = engine.raw_connection() 2369s 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s 2369s The above exception was the direct cause of the following exception: 2369s 2369s postgresql_psycopg2_engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 2369s 2369s @pytest.mark.db 2369s def test_self_join_date_columns(postgresql_psycopg2_engine): 2369s # GH 44421 2369s conn = postgresql_psycopg2_engine 2369s from sqlalchemy.sql import text 2369s 2369s create_table = text( 2369s """ 2369s CREATE TABLE person 2369s ( 2369s id serial constraint person_pkey primary key, 2369s created_dt timestamp with time zone 2369s ); 2369s 2369s INSERT INTO person 2369s VALUES (1, '2021-01-01T00:00:00Z'); 2369s """ 2369s ) 2369s > with conn.connect() as con: 2369s 2369s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3989: 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 2369s return self._connection_cls(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 2369s Connection._handle_dbapi_exception_noconnection( 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 2369s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 2369s self._dbapi_connection = engine.raw_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 2369s return self.pool.connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 2369s return _ConnectionFairy._checkout(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 2369s fairy = _ConnectionRecord.checkout(pool) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 2369s rec = pool._do_get() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 2369s return self._create_connection() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 2369s return _ConnectionRecord(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 2369s self.__connect() 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 2369s with util.safe_reraise(): 2369s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 2369s raise exc_value.with_traceback(exc_tb) 2369s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 2369s self.dbapi_connection = connection = pool._invoke_creator(self) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 2369s return dialect.connect(*cargs, **cparams) 2369s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 2369s return self.loaded_dbapi.connect(*cargs, **cparams) 2369s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2369s 2369s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 2369s connection_factory = None, cursor_factory = None 2369s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 2369s kwasync = {} 2369s 2369s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 2369s """ 2369s Create a new database connection. 2369s 2369s The connection parameters can be specified as a string: 2369s 2369s conn = psycopg2.connect("dbname=test user=postgres password=secret") 2369s 2369s or using a set of keyword arguments: 2369s 2369s conn = psycopg2.connect(database="test", user="postgres", password="secret") 2369s 2369s Or as a mix of both. The basic connection parameters are: 2369s 2369s - *dbname*: the database name 2369s - *database*: the database name (only as keyword argument) 2369s - *user*: user name used to authenticate 2369s - *password*: password used to authenticate 2369s - *host*: database host address (defaults to UNIX socket if not provided) 2369s - *port*: connection port number (defaults to 5432 if not provided) 2369s 2369s Using the *connection_factory* parameter a different class or connections 2369s factory can be specified. It should be a callable object taking a dsn 2369s argument. 2369s 2369s Using the *cursor_factory* parameter, a new default cursor factory will be 2369s used by cursor(). 2369s 2369s Using *async*=True an asynchronous connection will be created. *async_* is 2369s a valid alias (for Python versions where ``async`` is a keyword). 2369s 2369s Any other keyword parameter will be passed to the underlying client 2369s library: the list of supported parameters depends on the library version. 2369s 2369s """ 2369s kwasync = {} 2369s if 'async' in kwargs: 2369s kwasync['async'] = kwargs.pop('async') 2369s if 'async_' in kwargs: 2369s kwasync['async_'] = kwargs.pop('async_') 2369s 2369s dsn = _ext.make_dsn(dsn, **kwargs) 2369s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 2369s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 2369s E Is the server running on that host and accepting TCP/IP connections? 2369s E 2369s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 2369s 2369s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 2369s =============================== warnings summary =============================== 2369s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:895 2369s /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 2369s pytest.param("mysql_pymysql_engine", marks=pytest.mark.db), 2369s 2369s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:896 2369s /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 2369s pytest.param("mysql_pymysql_conn", marks=pytest.mark.db), 2369s 2369s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:900 2369s /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 2369s pytest.param("mysql_pymysql_engine_iris", marks=pytest.mark.db), 2369s 2369s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:901 2369s /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 2369s pytest.param("mysql_pymysql_conn_iris", marks=pytest.mark.db), 2369s 2369s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:905 2369s /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 2369s pytest.param("mysql_pymysql_engine_types", marks=pytest.mark.db), 2369s 2369s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:906 2369s /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 2369s pytest.param("mysql_pymysql_conn_types", marks=pytest.mark.db), 2369s 2369s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:910 2369s /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 2369s pytest.param("postgresql_psycopg2_engine", marks=pytest.mark.db), 2369s 2369s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:911 2369s /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 2369s pytest.param("postgresql_psycopg2_conn", marks=pytest.mark.db), 2369s 2369s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:915 2369s /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 2369s pytest.param("postgresql_psycopg2_engine_iris", marks=pytest.mark.db), 2369s 2369s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:916 2369s /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 2369s pytest.param("postgresql_psycopg2_conn_iris", marks=pytest.mark.db), 2369s 2369s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:920 2369s /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 2369s pytest.param("postgresql_psycopg2_engine_types", marks=pytest.mark.db), 2369s 2369s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:921 2369s /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 2369s pytest.param("postgresql_psycopg2_conn_types", marks=pytest.mark.db), 2369s 2369s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:954 2369s /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 2369s pytest.param("postgresql_adbc_conn", marks=pytest.mark.db), 2369s 2369s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:958 2369s /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 2369s pytest.param("postgresql_adbc_iris", marks=pytest.mark.db), 2369s 2369s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:959 2369s /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 2369s pytest.param("sqlite_adbc_iris", marks=pytest.mark.db), 2369s 2369s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:963 2369s /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 2369s pytest.param("postgresql_adbc_types", marks=pytest.mark.db), 2369s 2369s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:964 2369s /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 2369s pytest.param("sqlite_adbc_types", marks=pytest.mark.db), 2369s 2369s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3896 2369s /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 2369s @pytest.mark.db 2369s 2369s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3971 2369s /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 2369s @pytest.mark.db 2369s 2369s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_datetime.py:1143 2369s /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 2369s @pytest.mark.skip_ubsan 2369s 2369s io/test_sql.py: 1535 warnings 2369s tools/test_to_datetime.py: 978 warnings 2369s /usr/lib/python3/dist-packages/py/_process/forkedfunc.py:45: DeprecationWarning: This process (pid=18694) is multi-threaded, use of fork() may lead to deadlocks in the child. 2369s pid = os.fork() 2369s 2369s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 2369s /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-om5q4c0h' 2369s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 2369s 2369s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:429 2369s /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-dz2xmj4x' 2369s config.cache.set("cache/lastfailed", self.lastfailed) 2369s 2369s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 2369s /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-2fla8waa' 2369s session.config.cache.set(STEPWISE_CACHE_DIR, []) 2369s 2369s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 2369s =========================== short test summary info ============================ 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[mysql_pymysql_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[mysql_pymysql_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[postgresql_psycopg2_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[postgresql_psycopg2_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[mysql_pymysql_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[mysql_pymysql_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[postgresql_psycopg2_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[postgresql_psycopg2_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[mysql_pymysql_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[mysql_pymysql_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[postgresql_psycopg2_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[postgresql_psycopg2_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[mysql_pymysql_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[mysql_pymysql_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[postgresql_psycopg2_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[postgresql_psycopg2_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[mysql_pymysql_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[mysql_pymysql_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[postgresql_psycopg2_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[postgresql_psycopg2_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[mysql_pymysql_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[mysql_pymysql_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[postgresql_psycopg2_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[postgresql_psycopg2_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[mysql_pymysql_engine_types] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[mysql_pymysql_conn_types] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[postgresql_psycopg2_engine_types] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[postgresql_psycopg2_conn_types] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_procedure[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_procedure[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[2-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[2-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_on_public_schema[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_on_public_schema[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_update[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_update[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_view_postgres[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_view_postgres[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[mysql_pymysql_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[mysql_pymysql_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[postgresql_psycopg2_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[postgresql_psycopg2_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[mysql_pymysql_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[mysql_pymysql_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[postgresql_psycopg2_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[postgresql_psycopg2_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[mysql_pymysql_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[mysql_pymysql_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[postgresql_psycopg2_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[postgresql_psycopg2_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[mysql_pymysql_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[mysql_pymysql_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[mysql_pymysql_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[mysql_pymysql_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[postgresql_psycopg2_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[postgresql_psycopg2_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[mysql_pymysql_engine_types] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[mysql_pymysql_conn_types] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[postgresql_psycopg2_engine_types] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[postgresql_psycopg2_conn_types] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[mysql_pymysql_engine_types] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[mysql_pymysql_conn_types] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[postgresql_psycopg2_engine_types] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[postgresql_psycopg2_conn_types] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_conn] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label_multiindex[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label_multiindex[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[mysql_pymysql_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[mysql_pymysql_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[postgresql_psycopg2_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[postgresql_psycopg2_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[mysql_pymysql_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[mysql_pymysql_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[postgresql_psycopg2_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[postgresql_psycopg2_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[mysql_pymysql_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[mysql_pymysql_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[postgresql_psycopg2_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[postgresql_psycopg2_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[mysql_pymysql_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[mysql_pymysql_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[postgresql_psycopg2_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[postgresql_psycopg2_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[mysql_pymysql_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[mysql_pymysql_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[postgresql_psycopg2_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[postgresql_psycopg2_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[mysql_pymysql_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[mysql_pymysql_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[postgresql_psycopg2_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[postgresql_psycopg2_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[mysql_pymysql_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[mysql_pymysql_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[postgresql_psycopg2_engine_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[postgresql_psycopg2_conn_iris] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_default_type_conversion[postgresql_psycopg2_engine_types] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_default_type_conversion[postgresql_psycopg2_conn_types] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[mysql_pymysql_engine_types] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[mysql_pymysql_conn_types] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[postgresql_psycopg2_engine_types] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[postgresql_psycopg2_conn_types] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[None-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[None-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_table[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_table[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[mysql_pymysql_engine_types] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[mysql_pymysql_conn_types] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[postgresql_psycopg2_engine_types] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[postgresql_psycopg2_conn_types] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[postgresql_psycopg2_conn] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_conn] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_conn] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_engine] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_conn] 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_psycopg2_schema_support 2369s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_self_join_date_columns 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[mysql_pymysql_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[mysql_pymysql_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[postgresql_psycopg2_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[postgresql_psycopg2_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[mysql_pymysql_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[mysql_pymysql_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[postgresql_psycopg2_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[postgresql_psycopg2_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[mysql_pymysql_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[mysql_pymysql_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[postgresql_psycopg2_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[postgresql_psycopg2_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[mysql_pymysql_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[mysql_pymysql_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[postgresql_psycopg2_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[postgresql_psycopg2_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[mysql_pymysql_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[mysql_pymysql_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[postgresql_psycopg2_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[postgresql_psycopg2_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[mysql_pymysql_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[mysql_pymysql_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[postgresql_psycopg2_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[postgresql_psycopg2_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[mysql_pymysql_engine_types] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[mysql_pymysql_conn_types] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[postgresql_psycopg2_engine_types] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[postgresql_psycopg2_conn_types] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_procedure[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_procedure[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[2-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[2-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_on_public_schema[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_on_public_schema[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_update[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_update[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_view_postgres[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_view_postgres[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[mysql_pymysql_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[mysql_pymysql_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[postgresql_psycopg2_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[postgresql_psycopg2_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[mysql_pymysql_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[mysql_pymysql_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[postgresql_psycopg2_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[postgresql_psycopg2_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[mysql_pymysql_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[mysql_pymysql_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[postgresql_psycopg2_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[postgresql_psycopg2_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[mysql_pymysql_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[mysql_pymysql_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[mysql_pymysql_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[mysql_pymysql_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[postgresql_psycopg2_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[postgresql_psycopg2_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[mysql_pymysql_engine_types] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[mysql_pymysql_conn_types] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[postgresql_psycopg2_engine_types] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[postgresql_psycopg2_conn_types] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[mysql_pymysql_engine_types] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[mysql_pymysql_conn_types] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[postgresql_psycopg2_engine_types] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[postgresql_psycopg2_conn_types] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_conn] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label_multiindex[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label_multiindex[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[mysql_pymysql_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[mysql_pymysql_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[postgresql_psycopg2_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[postgresql_psycopg2_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[mysql_pymysql_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[mysql_pymysql_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[postgresql_psycopg2_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[postgresql_psycopg2_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[mysql_pymysql_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[mysql_pymysql_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[postgresql_psycopg2_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[postgresql_psycopg2_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[mysql_pymysql_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[mysql_pymysql_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[postgresql_psycopg2_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[postgresql_psycopg2_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[mysql_pymysql_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[mysql_pymysql_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[postgresql_psycopg2_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[postgresql_psycopg2_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[mysql_pymysql_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[mysql_pymysql_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[postgresql_psycopg2_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[postgresql_psycopg2_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[mysql_pymysql_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[mysql_pymysql_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[postgresql_psycopg2_engine_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[postgresql_psycopg2_conn_iris] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_default_type_conversion[postgresql_psycopg2_engine_types] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_default_type_conversion[postgresql_psycopg2_conn_types] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[mysql_pymysql_engine_types] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[mysql_pymysql_conn_types] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[postgresql_psycopg2_engine_types] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[postgresql_psycopg2_conn_types] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[None-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[None-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_table[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_table[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[mysql_pymysql_engine_types] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[mysql_pymysql_conn_types] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[postgresql_psycopg2_engine_types] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[postgresql_psycopg2_conn_types] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[postgresql_psycopg2_conn] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_conn] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_conn] 2369s 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] 2369s 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] 2369s 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] 2369s 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] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_engine] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_conn] 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_psycopg2_schema_support 2369s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_self_join_date_columns 2369s = 588 failed, 1481 passed, 400 skipped, 54 xfailed, 2536 warnings, 592 errors in 701.07s (0:11:41) = 2370s autopkgtest [18:03:10]: test ignoredtests: -----------------------] 2375s autopkgtest [18:03:15]: test ignoredtests: - - - - - - - - - - results - - - - - - - - - - 2375s ignoredtests PASS 2375s autopkgtest [18:03:15]: @@@@@@@@@@@@@@@@@@@@ summary 2375s command1 PASS 2375s unittests3 PASS 2375s ignoredtests PASS 2393s nova [W] Using flock in prodstack6-arm64 2393s Creating nova instance adt-questing-arm64-pandas-20250506-172339-juju-7f2275-prod-proposed-migration-environment-23-d8235e52-98a0-4e47-8dcd-6da08e0a828f from image adt/ubuntu-questing-arm64-server-20250506.img (UUID dbd2b533-f985-4adb-816b-f648e6478ce9)... 2393s nova [W] Timed out waiting for 993b7962-1a6f-4f34-8a72-ce210aac6e94 to get deleted.